Skip to content

Commit edd4e7b

Browse files
feat(api): add webhook signature verification
1 parent 21501a9 commit edd4e7b

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.openai.services.async
4+
5+
import com.openai.TestServerExtension
6+
import com.openai.client.okhttp.OpenAIOkHttpClientAsync
7+
import com.openai.core.http.Headers
8+
import org.junit.jupiter.api.Test
9+
import org.junit.jupiter.api.extension.ExtendWith
10+
11+
@ExtendWith(TestServerExtension::class)
12+
internal class WebhookServiceAsyncTest {
13+
14+
@Test
15+
fun unwrap() {
16+
val client =
17+
OpenAIOkHttpClientAsync.builder()
18+
.baseUrl(TestServerExtension.BASE_URL)
19+
.apiKey("My API Key")
20+
.build()
21+
val webhookServiceAsync = client.webhooks()
22+
23+
val payload =
24+
"{\"id\":\"id\",\"created_at\":0,\"data\":{\"id\":\"id\"},\"type\":\"batch.cancelled\",\"object\":\"event\"}"
25+
val webhookSecret = "whsec_c2VjcmV0Cg=="
26+
val headers = Headers.builder().build()
27+
28+
webhookServiceAsync.unwrap(payload).validate()
29+
}
30+
}

openai-java-core/src/test/kotlin/com/openai/services/blocking/WebhookServiceTest.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<<<<<<< HEAD
12
// File generated from our OpenAPI spec by Stainless.
23

34
package com.openai.services.blocking
@@ -226,3 +227,36 @@ internal class WebhookServiceTest {
226227
}
227228
}
228229
}
230+
||||||| parent of 8235a47f (feat(api): add webhook signature verification)
231+
=======
232+
// File generated from our OpenAPI spec by Stainless.
233+
234+
package com.openai.services.blocking
235+
236+
import com.openai.TestServerExtension
237+
import com.openai.client.okhttp.OpenAIOkHttpClient
238+
import com.openai.core.http.Headers
239+
import org.junit.jupiter.api.Test
240+
import org.junit.jupiter.api.extension.ExtendWith
241+
242+
@ExtendWith(TestServerExtension::class)
243+
internal class WebhookServiceTest {
244+
245+
@Test
246+
fun unwrap() {
247+
val client =
248+
OpenAIOkHttpClient.builder()
249+
.baseUrl(TestServerExtension.BASE_URL)
250+
.apiKey("My API Key")
251+
.build()
252+
val webhookService = client.webhooks()
253+
254+
val payload =
255+
"{\"id\":\"id\",\"created_at\":0,\"data\":{\"id\":\"id\"},\"type\":\"batch.cancelled\",\"object\":\"event\"}"
256+
val webhookSecret = "whsec_c2VjcmV0Cg=="
257+
val headers = Headers.builder().build()
258+
259+
webhookService.unwrap(payload).validate()
260+
}
261+
}
262+
>>>>>>> 8235a47f (feat(api): add webhook signature verification)

0 commit comments

Comments
 (0)