Skip to content

Commit

Permalink
Trim event API version when matching (#1727)
Browse files Browse the repository at this point in the history
* Trim event API version when matching

* remove bad assert
  • Loading branch information
anniel-stripe authored Jan 17, 2024
1 parent 8ffb825 commit 5c17e2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private boolean apiVersionMatch() {
// Trim the locally configured API version to not include beta headers, since the payload won't
// have any.
String localApiVersion = StringUtils.trimApiVersion(Stripe.stripeVersion);
return localApiVersion.equals(this.apiVersion);
return localApiVersion.equals(StringUtils.trimApiVersion(this.apiVersion));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void testFailureOnApiVersionMisMatch() throws Exception {
}

@Test
public void testIgnoresBetaHeadersWhenDeterminingMatch() throws Exception {
public void testIgnoresBetaHeadersInLibraryVersionWhenDeterminingMatch() throws Exception {
final String data = getCurrentEventStringFixture();
final Event event = ApiResource.GSON.fromJson(data, Event.class);

Expand All @@ -156,6 +156,19 @@ public void testIgnoresBetaHeadersWhenDeterminingMatch() throws Exception {
verifyDeserializedStripeObject(deserializer.getObject().get());
}

@Test
public void testIgnoresBetaHeadersInEventVersionWhenDeterminingMatch() throws Exception {
final String data = getCurrentEventStringFixture();
final Event event = ApiResource.GSON.fromJson(data, Event.class);
event.apiVersion = CURRENT_EVENT_VERSION + "; some_beta=v1; some_beta=v2";

Stripe.stripeVersion = CURRENT_EVENT_VERSION;
EventDataObjectDeserializer deserializer = event.getDataObjectDeserializer();

assertTrue(deserializer.getObject().isPresent());
verifyDeserializedStripeObject(deserializer.getObject().get());
}

@Test
public void testApiVersionMismatchReportedEvenWhenBetaHeadersPresent() throws Exception {
final String data = getCurrentEventStringFixture();
Expand Down

0 comments on commit 5c17e2e

Please sign in to comment.