Skip to content

Commit c4cfc4b

Browse files
committed
test: add snapshot test for linkIdentityWithIdToken method
1 parent e23515c commit c4cfc4b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Tests/AuthTests/AuthClientTests.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,43 @@ final class AuthClientTests: XCTestCase {
484484
expectNoDifference(receivedURL.value?.absoluteString, url)
485485
}
486486

487+
func testLinkIdentityWithIdToken() async throws {
488+
Mock(
489+
url: clientURL.appendingPathComponent("token"),
490+
ignoreQuery: true,
491+
statusCode: 200,
492+
data: [.post: MockData.session]
493+
)
494+
.snapshotRequest {
495+
#"""
496+
curl \
497+
--request POST \
498+
--header "Content-Length: 166" \
499+
--header "Content-Type: application/json" \
500+
--header "X-Client-Info: auth-swift/0.0.0" \
501+
--header "X-Supabase-Api-Version: 2024-01-01" \
502+
--header "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" \
503+
--data "{\"access_token\":\"access-token\",\"gotrue_meta_security\":{\"captcha_token\":\"captcha-token\"},\"id_token\":\"id-token\",\"link_identity\":true,\"nonce\":\"nonce\",\"provider\":\"apple\"}" \
504+
"http://localhost:54321/auth/v1/token?grant_type=id_token"
505+
"""#
506+
}
507+
.register()
508+
509+
let sut = makeSUT()
510+
511+
try await sut.linkIdentityWithIdToken(
512+
credentials: OpenIDConnectCredentials(
513+
provider: .apple,
514+
idToken: "id-token",
515+
accessToken: "access-token",
516+
nonce: "nonce",
517+
gotrueMetaSecurity: AuthMetaSecurity(
518+
captchaToken: "captcha-token"
519+
)
520+
)
521+
)
522+
}
523+
487524
func testAdminListUsers() async throws {
488525
Mock(
489526
url: clientURL.appendingPathComponent("admin/users"),

0 commit comments

Comments
 (0)