Skip to content

Commit 2a5b01a

Browse files
authored
Fix: Apple login identityToken (#82)
* Testing * Fix test case * Update .codecov.yml
1 parent 8cee8aa commit 2a5b01a

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ coverage:
55
status:
66
patch:
77
default:
8-
target: 55
8+
target: 49
99
changes: false
1010
project:
1111
default:

Sources/ParseSwift/Authentication/3rd Party/ParseApple.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public struct ParseApple<AuthenticatedUser: ParseUser>: ParseAuthentication {
3333
/// to a string.
3434
func makeDictionary(user: String,
3535
identityToken: Data) throws -> [String: String] {
36-
let identityTokenString = identityToken.hexEncodedString()
36+
guard let identityTokenString = String(data: identityToken, encoding: .utf8) else {
37+
throw ParseError(code: .unknownError, message: "Couldn't convert identityToken to String")
38+
}
3739
return [AuthenticationKeys.id.rawValue: user,
3840
AuthenticationKeys.token.rawValue: identityTokenString]
3941
}

Tests/ParseSwiftTests/ParseAppleTests.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,14 @@ class ParseAppleTests: XCTestCase {
9494
}
9595

9696
func testAuthenticationKeys() throws {
97-
let tokenData = Data([0, 1, 127, 128, 255])
97+
guard let tokenData = "test".data(using: .utf8) else {
98+
XCTFail("Should have created Data")
99+
return
100+
}
98101
let authData = try ParseApple<User>
99102
.AuthenticationKeys.id.makeDictionary(user: "testing",
100103
identityToken: tokenData)
101-
XCTAssertEqual(authData, ["id": "testing", "token": "00017f80ff"])
104+
XCTAssertEqual(authData, ["id": "testing", "token": "test"])
102105
}
103106

104107
func testLogin() throws {

0 commit comments

Comments
 (0)