Skip to content

Commit 48aca33

Browse files
committed
chore: use new webhook fixtures
1 parent c1839b9 commit 48aca33

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

examples

Submodule examples updated 44 files

src/test/java/com/easypost/Fixtures.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,6 @@ public static String reportIdPrefix() {
112112
return "shprep_";
113113
}
114114

115-
/**
116-
* Get the default webhook URL.
117-
*
118-
* @return The default webhook URL
119-
*/
120-
public static String webhookUrl() {
121-
return Objects.requireNonNull(getFixtureData()).webhookUrl;
122-
}
123-
124115
/**
125116
* Get the first default address.
126117
*
@@ -302,6 +293,33 @@ public static byte[] eventBytes() {
302293
return data;
303294
}
304295

296+
/**
297+
* Get the default webhook URL.
298+
*
299+
* @return The default webhook URL
300+
*/
301+
public static String webhookHmacSignature() {
302+
return Objects.requireNonNull(getFixtureData()).webhookHmacSignature;
303+
}
304+
305+
/**
306+
* Get the default webhook URL.
307+
*
308+
* @return The default webhook URL
309+
*/
310+
public static String webhookSecret() {
311+
return Objects.requireNonNull(getFixtureData()).webhookSecret;
312+
}
313+
314+
/**
315+
* Get the default webhook URL.
316+
*
317+
* @return The default webhook URL
318+
*/
319+
public static String webhookUrl() {
320+
return Objects.requireNonNull(getFixtureData()).webhookUrl;
321+
}
322+
305323
/**
306324
* Get the default credit card details.
307325
*

src/test/java/com/easypost/WebhookTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import static org.junit.jupiter.api.Assertions.assertThrows;
2222
import static org.junit.jupiter.api.Assertions.assertTrue;
2323

24-
@TestMethodOrder (MethodOrderer.OrderAnnotation.class)
24+
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
2525
public final class WebhookTest {
2626
private static String testWebhookId = null;
2727
private static TestUtils.VCR vcr;
@@ -158,14 +158,13 @@ public void testDelete() throws EasyPostException {
158158
*/
159159
@Test
160160
public void testValidateWebhook() throws EasyPostException {
161-
String webhookSecret = "sécret";
162161
Map<String, Object> headers = ImmutableMap.of("X-Hmac-Signature",
163-
"hmac-sha256-hex=e93977c8ccb20363d51a62b3fe1fc402b7829be1152da9e88cf9e8d07115a46b");
162+
Fixtures.webhookHmacSignature());
164163

165-
Event event = Utilities.validateWebhook(Fixtures.eventBytes(), headers, webhookSecret);
164+
Event event = Utilities.validateWebhook(Fixtures.eventBytes(), headers, Fixtures.webhookSecret());
166165

167-
assertEquals("batch.created", event.getDescription());
168-
assertEquals("batch_123...", event.getResult().get("id"));
166+
assertEquals("tracker.updated", event.getDescription());
167+
assertEquals(614.4, event.getResult().get("weight")); // Ensure we convert floats properly
169168
}
170169

171170
/**

src/test/java/com/easypost/fixtures/FixtureStructure.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ public final class FixtureStructure {
7676
@SerializedName ("users")
7777
public Users users;
7878

79+
@SerializedName ("webhook_hmac_signature")
80+
public String webhookHmacSignature;
81+
82+
@SerializedName ("webhook_secret")
83+
public String webhookSecret;
84+
7985
@SerializedName ("webhook_url")
8086
public String webhookUrl;
8187

0 commit comments

Comments
 (0)