diff --git a/Sources/ParseSwift/API/Responses.swift b/Sources/ParseSwift/API/Responses.swift index a2842bb03..10b189455 100644 --- a/Sources/ParseSwift/API/Responses.swift +++ b/Sources/ParseSwift/API/Responses.swift @@ -14,50 +14,93 @@ struct CreateResponse: Decodable { var updatedAt: Date { return createdAt } + var sessionToken: String? - func apply(to object: T) -> T where T: ParseObject { + func setResponseProperties(on object: T) -> T where T: ParseObject { var object = object object.objectId = objectId object.createdAt = createdAt object.updatedAt = updatedAt return object } + + func apply(to object: T) -> T where T: ParseObject { + setResponseProperties(on: object) + } + + func apply(to user: T) -> T where T: ParseUser { + var user = setResponseProperties(on: user) + user.password = nil + return user + } + } struct ReplaceResponse: Decodable { var createdAt: Date? var updatedAt: Date? + var sessionToken: String? - func apply(to object: T) throws -> T where T: ParseObject { + func setResponseProperties(on object: T) throws -> T where T: ParseObject { guard let objectId = object.objectId else { - throw ParseError(code: .missingObjectId, - message: "Response from server should not have an objectId of nil") + throw ParseError( + code: .missingObjectId, + message: "Response from server should not have an objectId of nil" + ) } guard let createdAt = createdAt else { guard let updatedAt = updatedAt else { - throw ParseError(code: .otherCause, - message: "Response from server should not have an updatedAt of nil") + throw ParseError( + code: .otherCause, + message: "Response from server should not have an updatedAt of nil" + ) } - return UpdateResponse(updatedAt: updatedAt).apply(to: object) + let response = UpdateResponse( + updatedAt: updatedAt, + sessionToken: sessionToken + ).apply(to: object) + + return response } - return CreateResponse(objectId: objectId, - createdAt: createdAt).apply(to: object) + let response = CreateResponse( + objectId: objectId, + createdAt: createdAt, + sessionToken: sessionToken + ).apply(to: object) + + return response + } + + func apply(to object: T) throws -> T where T: ParseObject { + try setResponseProperties(on: object) + } + + func apply(to user: T) throws -> T where T: ParseUser { + var user = try setResponseProperties(on: user) + user.password = nil // password should be removed + return user } } struct UpdateResponse: Decodable { var updatedAt: Date + var sessionToken: String? - func apply(to object: T) -> T where T: ParseObject { + func setResponseProperties(on object: T) -> T where T: ParseObject { var object = object object.updatedAt = updatedAt return object } -} -struct UpdateSessionTokenResponse: Decodable { - var updatedAt: Date - let sessionToken: String? + func apply(to object: T) -> T where T: ParseObject { + setResponseProperties(on: object) + } + + func apply(to user: T) -> T where T: ParseUser { + var user = setResponseProperties(on: user) + user.password = nil // password should be removed + return user + } } // MARK: ParseObject Batch @@ -70,29 +113,50 @@ struct BatchResponse: Codable { var objectId: String? var createdAt: Date? var updatedAt: Date? + var sessionToken: String? func asCreateResponse() throws -> CreateResponse { guard let objectId = objectId else { - throw ParseError(code: .missingObjectId, - message: "Response from server should not have an objectId of nil") + throw ParseError( + code: .missingObjectId, + message: "Response from server should not have an objectId of nil" + ) } guard let createdAt = createdAt else { - throw ParseError(code: .otherCause, - message: "Response from server should not have an createdAt of nil") + throw ParseError( + code: .otherCause, + message: "Response from server should not have an createdAt of nil" + ) } - return CreateResponse(objectId: objectId, createdAt: createdAt) + + let response = CreateResponse( + objectId: objectId, + createdAt: createdAt, sessionToken: sessionToken + ) + + return response } func asReplaceResponse() -> ReplaceResponse { - ReplaceResponse(createdAt: createdAt, updatedAt: updatedAt) + ReplaceResponse( + createdAt: createdAt, + updatedAt: updatedAt, + sessionToken: sessionToken + ) } func asUpdateResponse() throws -> UpdateResponse { guard let updatedAt = updatedAt else { - throw ParseError(code: .otherCause, - message: "Response from server should not have an updatedAt of nil") + throw ParseError( + code: .otherCause, + message: "Response from server should not have an updatedAt of nil" + ) } - return UpdateResponse(updatedAt: updatedAt) + let response = UpdateResponse( + updatedAt: updatedAt, + sessionToken: sessionToken + ) + return response } func apply(to object: T, method: API.Method) throws -> T where T: ParseObject { @@ -125,14 +189,14 @@ struct LoginSignupResponse: Codable { var updatedAt: Date? let username: String? - func applySignup(to object: T) -> T where T: ParseUser { - var object = object - object.objectId = objectId - object.createdAt = createdAt - object.updatedAt = createdAt - object.password = nil // password should be removed + func apply(to user: T) -> T where T: ParseUser { + var user = user + user.objectId = objectId + user.createdAt = createdAt + user.updatedAt = updatedAt ?? createdAt + user.password = nil // password should be removed - return object + return user } } diff --git a/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift b/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift index 7c22c2794..1d49181ec 100644 --- a/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift +++ b/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift @@ -407,8 +407,8 @@ public extension ParseUser { return API.Command(method: .PUT, path: endpoint, body: mutableSelf) { (data) -> Self in - let user = try ParseCoding.jsonDecoder().decode(UpdateSessionTokenResponse.self, from: data) - mutableSelf.updatedAt = user.updatedAt + let user = try ParseCoding.jsonDecoder().decode(UpdateResponse.self, from: data) + mutableSelf = user.apply(to: mutableSelf) if let sessionToken = user.sessionToken { await Self.setCurrentContainer(.init(currentUser: mutableSelf, sessionToken: sessionToken)) @@ -434,9 +434,8 @@ public extension ParseUser { return API.Command(method: .PUT, path: endpoint, body: body) { (data) -> Self in - let user = try ParseCoding.jsonDecoder().decode(UpdateSessionTokenResponse.self, from: data) - var currentUser = currentStrippedUser - currentUser.updatedAt = user.updatedAt + let user = try ParseCoding.jsonDecoder().decode(UpdateResponse.self, from: data) + var currentUser = user.apply(to: currentStrippedUser) currentUser.authData = body.authData if let sessionToken = user.sessionToken { await Self.setCurrentContainer(.init(currentUser: currentUser, diff --git a/Sources/ParseSwift/Objects/ParseUser+async.swift b/Sources/ParseSwift/Objects/ParseUser+async.swift index 3e5994802..9b334f2ce 100644 --- a/Sources/ParseSwift/Objects/ParseUser+async.swift +++ b/Sources/ParseSwift/Objects/ParseUser+async.swift @@ -570,7 +570,9 @@ internal extension ParseUser { let command: API.Command! switch method { case .save: - command = try await self.saveCommand(ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig) + command = try await self.saveCommand( + ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig + ) case .create: command = try await self.createCommand() case .replace: diff --git a/Sources/ParseSwift/Objects/ParseUser.swift b/Sources/ParseSwift/Objects/ParseUser.swift index 010cf8323..80feeb12d 100644 --- a/Sources/ParseSwift/Objects/ParseUser.swift +++ b/Sources/ParseSwift/Objects/ParseUser.swift @@ -53,8 +53,10 @@ public extension ParseUser { func mergeParse(with object: Self) throws -> Self { guard hasSameObjectId(as: object) else { - throw ParseError(code: .otherCause, - message: "objectId's of objects do not match") + throw ParseError( + code: .otherCause, + message: "objectId's of objects do not match" + ) } var updatedUser = self if shouldRestoreKey(\.ACL, @@ -262,28 +264,45 @@ extension ParseUser { } } - internal static func loginCommand(username: String? = nil, - email: String? = nil, - password: String, - // swiftlint:disable:next line_length - authData: [String: [String: String]?]? = nil) -> API.Command { - - let body = SignupLoginBody(username: username, - email: email, - password: password, - authData: authData) - return API.Command(method: .POST, - path: .login, - body: body) { (data) async throws -> Self in - let sessionToken = try ParseCoding.jsonDecoder().decode(LoginSignupResponse.self, from: data).sessionToken - let user = try ParseCoding.jsonDecoder().decode(Self.self, from: data) - + internal static func loginCommand( + username: String? = nil, + email: String? = nil, + password: String, + authData: [String: [String: String]?]? = nil + ) -> API.Command { + + let body = SignupLoginBody( + username: username, + email: email, + password: password, + authData: authData + ) + let command = API.Command( + method: .POST, + path: .login, + body: body + ) { (data) async throws -> Self in + let userResponse = try ParseCoding + .jsonDecoder() + .decode( + LoginSignupResponse.self, + from: data + ) + let sessionToken = userResponse.sessionToken + var user = try ParseCoding + .jsonDecoder() + .decode( + Self.self, + from: data + ) + user = userResponse.apply(to: user) await Self.setCurrentContainer(.init( currentUser: user, sessionToken: sessionToken )) return user } + return command } /** @@ -481,18 +500,29 @@ extension ParseUser { internal static func loginAsCommand(objectId: String) throws -> API.Command { let body = LoginAsBody(userId: objectId) - return API.Command(method: .POST, - path: .loginAs, - body: body) { (data) async throws -> Self in - let sessionToken = try ParseCoding.jsonDecoder() - .decode(LoginSignupResponse.self, from: data).sessionToken - let user = try ParseCoding.jsonDecoder().decode(Self.self, from: data) - await Self.setCurrentContainer(.init( - currentUser: user, - sessionToken: sessionToken - )) + let command = API.Command( + method: .POST, + path: .loginAs, + body: body + ) { (data) async throws -> Self in + let userResponse = try ParseCoding + .jsonDecoder() + .decode( + LoginSignupResponse.self, + from: data + ) + let sessionToken = userResponse.sessionToken + var user = try ParseCoding.jsonDecoder().decode(Self.self, from: data) + user = userResponse.apply(to: user) + await Self.setCurrentContainer( + .init( + currentUser: user, + sessionToken: sessionToken + ) + ) return user } + return command } } @@ -613,29 +643,37 @@ extension ParseUser { [issue](https://github.com/parse-community/parse-server/issues/7784) to be addressed on the Parse Server, othewise you should set `usingPost = false`. */ - public static func verifyPassword(password: String, - usingPost: Bool = false, - options: API.Options = [], - callbackQueue: DispatchQueue = .main, - completion: @escaping (Result) -> Void) { + public static func verifyPassword( + password: String, + usingPost: Bool = false, + options: API.Options = [], + callbackQueue: DispatchQueue = .main, + completion: @escaping (Result) -> Void + ) { Task { var options = options options.insert(.cachePolicy(.reloadIgnoringLocalCacheData)) let currentUserName = try? await BaseParseUser.current().username let username = currentUserName ?? "" let method: API.Method = usingPost ? .POST : .GET - await verifyPasswordCommand(username: username, - password: password, - method: method) - .execute(options: options, - callbackQueue: callbackQueue, - completion: completion) + await verifyPasswordCommand( + username: username, + password: password, + method: method + ) + .execute( + options: options, + callbackQueue: callbackQueue, + completion: completion + ) } } - internal static func verifyPasswordCommand(username: String, - password: String, - method: API.Method) -> API.Command { + internal static func verifyPasswordCommand( + username: String, + password: String, + method: API.Method + ) -> API.Command { let loginBody: SignupLoginBody? let params: [String: String]? @@ -648,20 +686,44 @@ extension ParseUser { params = nil } - return API.Command(method: method, - path: .verifyPassword, - params: params, - body: loginBody) { (data) -> Self in - var sessionToken = await Self.currentContainer()?.sessionToken - if let decodedSessionToken = try? ParseCoding.jsonDecoder() - .decode(LoginSignupResponse.self, from: data).sessionToken { - sessionToken = decodedSessionToken + let command = API.Command( + method: method, + path: .verifyPassword, + params: params, + body: loginBody + ) { (data) -> Self in + + do { + + let userResponse = try ParseCoding + .jsonDecoder() + .decode( + ReplaceResponse.self, + from: data + ) + + var user = try ParseCoding + .jsonDecoder() + .decode( + Self.self, + from: data + ) + user = try userResponse.apply(to: user) + + return user + + } catch { + + let parseError = ParseError( + code: .otherCause, + message: "Could not verify password", + swift: error + ) + throw parseError } - let user = try ParseCoding.jsonDecoder().decode(Self.self, from: data) - await Self.setCurrentContainer(.init(currentUser: user, - sessionToken: sessionToken)) - return user } + + return command } } @@ -819,14 +881,25 @@ extension ParseUser { } internal static func signupCommand(body: SignupLoginBody) throws -> API.Command { - API.Command(method: .POST, - path: .users, - body: body) { (data) -> Self in - - let sessionToken = try ParseCoding.jsonDecoder() - .decode(LoginSignupResponse.self, from: data).sessionToken - var user = try ParseCoding.jsonDecoder().decode(Self.self, from: data) - + API.Command( + method: .POST, + path: .users, + body: body + ) { (data) -> Self in + + let userResponse = try ParseCoding + .jsonDecoder() + .decode( + LoginSignupResponse.self, + from: data) + let sessionToken = userResponse.sessionToken + var user = try ParseCoding + .jsonDecoder() + .decode( + Self.self, + from: data + ) + user = userResponse.apply(to: user) if user.username == nil { if let username = body.username { user.username = username @@ -837,25 +910,37 @@ extension ParseUser { user.authData = authData } } - await Self.setCurrentContainer(.init(currentUser: user, - sessionToken: sessionToken)) + await Self.setCurrentContainer( + .init( + currentUser: user, + sessionToken: sessionToken + ) + ) return user } } internal func signupCommand() throws -> API.Command { - API.Command(method: .POST, - path: endpoint, - body: self) { (data) -> Self in - - let response = try ParseCoding.jsonDecoder() - .decode(LoginSignupResponse.self, from: data) - let user = response.applySignup(to: self) - await Self.setCurrentContainer(.init( - currentUser: user, - sessionToken: response.sessionToken - )) + API.Command( + method: .POST, + path: endpoint, + body: self + ) { (data) -> Self in + + let userResponse = try ParseCoding + .jsonDecoder() + .decode( + LoginSignupResponse.self, + from: data + ) + let user = userResponse.apply(to: self) + await Self.setCurrentContainer( + .init( + currentUser: user, + sessionToken: userResponse.sessionToken + ) + ) return user } } @@ -982,10 +1067,12 @@ extension ParseUser { let method = Method.save Task { do { - let object = try await command(method: method, - ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, - options: options, - callbackQueue: callbackQueue) + let object = try await command( + method: method, + ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, + options: options, + callbackQueue: callbackQueue + ) callbackQueue.async { completion(.success(object)) } @@ -1106,20 +1193,30 @@ extension ParseUser { // MARK: Saving ParseObjects - private func createCommand() async throws -> API.Command { - var object = self - if object.ACL == nil, + var user = self + if user.ACL == nil, let acl = try? await ParseACL.defaultACL() { - object.ACL = acl + user.ACL = acl } let mapper = { (data) -> Self in - try ParseCoding.jsonDecoder().decode(CreateResponse.self, from: data).apply(to: object) + try ParseCoding + .jsonDecoder() + .decode( + CreateResponse.self, + from: data + ).apply(to: user) } - return API.Command(method: .POST, - path: try await endpoint(.POST), - body: object, - mapper: mapper) + let path = try await endpoint(.POST) + let command = API.Command( + method: .POST, + path: path, + body: user, + mapper: mapper + ) + return command } + // swiftlint:disable:next function_body_length func replaceCommand() async throws -> API.Command { guard self.objectId != nil else { throw ParseError(code: .missingObjectId, @@ -1133,25 +1230,57 @@ extension ParseUser { } } let mapper = { (data: Data) -> Self in - var updatedObject = self - updatedObject.originalData = nil - updatedObject = try ParseCoding.jsonDecoder().decode(ReplaceResponse.self, - from: data).apply(to: updatedObject) + var updatedUser = self + updatedUser.originalData = nil + let userResponse = try ParseCoding + .jsonDecoder() + .decode( + ReplaceResponse.self, + from: data + ) // MARK: The lines below should be removed when server supports PATCH. guard let originalData = self.originalData, - let original = try? ParseCoding.jsonDecoder().decode(Self.self, - from: originalData), - original.hasSameObjectId(as: updatedObject) else { - return updatedObject - } - return try updatedObject.merge(with: original) + let originalUser = try? ParseCoding + .jsonDecoder() + .decode( + Self.self, + from: originalData + ) else { + updatedUser = try userResponse.apply(to: updatedUser) + return updatedUser + } + + guard originalUser.hasSameObjectId(as: updatedUser) else { + throw ParseError( + code: .otherCause, + message: "objectId's of objects do not match" + ) + } + + var mergedUser = try updatedUser.merge(with: originalUser) + mergedUser = try userResponse.apply(to: mergedUser) + if let sessionToken = userResponse.sessionToken { + // Only need to update here because sessionToken changed. + // Any other changes will be saved to the Keychain later. + await Self.setCurrentContainer( + .init( + currentUser: mergedUser, + sessionToken: sessionToken + ) + ) + } + return mergedUser } - return API.Command(method: .PUT, - path: endpoint, - body: mutableSelf, - mapper: mapper) + let command = API.Command( + method: .PUT, + path: endpoint, + body: mutableSelf, + mapper: mapper + ) + return command } + // swiftlint:disable:next function_body_length func updateCommand() async throws -> API.Command { guard self.objectId != nil else { throw ParseError(code: .missingObjectId, @@ -1165,22 +1294,53 @@ extension ParseUser { } } let mapper = { (data: Data) -> Self in - var updatedObject = self - updatedObject.originalData = nil - updatedObject = try ParseCoding.jsonDecoder().decode(UpdateResponse.self, - from: data).apply(to: updatedObject) + var updatedUser = self + updatedUser.originalData = nil + let userResponse = try ParseCoding + .jsonDecoder() + .decode( + UpdateResponse.self, + from: data + ) guard let originalData = self.originalData, - let original = try? ParseCoding.jsonDecoder().decode(Self.self, - from: originalData), - original.hasSameObjectId(as: updatedObject) else { - return updatedObject - } - return try updatedObject.merge(with: original) + let originalUser = try? ParseCoding + .jsonDecoder() + .decode( + Self.self, + from: originalData + ) else { + updatedUser = userResponse.apply(to: updatedUser) + return updatedUser + } + + guard originalUser.hasSameObjectId(as: updatedUser) else { + throw ParseError( + code: .otherCause, + message: "objectId's of objects do not match" + ) + } + + var mergedUser = try updatedUser.merge(with: originalUser) + mergedUser = userResponse.apply(to: mergedUser) + if let sessionToken = userResponse.sessionToken { + // Only need to update here because sessionToken changed. + // Any other changes will be saved to the Keychain later. + await Self.setCurrentContainer( + .init( + currentUser: mergedUser, + sessionToken: sessionToken + ) + ) + } + return mergedUser } - return API.Command(method: .PATCH, - path: endpoint, - body: mutableSelf, - mapper: mapper) + let command = API.Command( + method: .PATCH, + path: endpoint, + body: mutableSelf, + mapper: mapper + ) + return command } } @@ -1295,12 +1455,14 @@ public extension Sequence where Element: ParseUser { let method = Method.save Task { do { - let objects = try await batchCommand(method: method, - batchLimit: limit, - transaction: transaction, - ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, - options: options, - callbackQueue: callbackQueue) + let objects = try await batchCommand( + method: method, + batchLimit: limit, + transaction: transaction, + ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, + options: options, + callbackQueue: callbackQueue + ) callbackQueue.async { completion(.success(objects)) } @@ -1340,11 +1502,13 @@ public extension Sequence where Element: ParseUser { let method = Method.create Task { do { - let objects = try await batchCommand(method: method, - batchLimit: limit, - transaction: transaction, - options: options, - callbackQueue: callbackQueue) + let objects = try await batchCommand( + method: method, + batchLimit: limit, + transaction: transaction, + options: options, + callbackQueue: callbackQueue + ) callbackQueue.async { completion(.success(objects)) } @@ -1385,11 +1549,13 @@ public extension Sequence where Element: ParseUser { let method = Method.replace Task { do { - let objects = try await batchCommand(method: method, - batchLimit: limit, - transaction: transaction, - options: options, - callbackQueue: callbackQueue) + let objects = try await batchCommand( + method: method, + batchLimit: limit, + transaction: transaction, + options: options, + callbackQueue: callbackQueue + ) callbackQueue.async { completion(.success(objects)) } @@ -1430,11 +1596,13 @@ public extension Sequence where Element: ParseUser { let method = Method.update Task { do { - let objects = try await batchCommand(method: method, - batchLimit: limit, - transaction: transaction, - options: options, - callbackQueue: callbackQueue) + let objects = try await batchCommand( + method: method, + batchLimit: limit, + transaction: transaction, + options: options, + callbackQueue: callbackQueue + ) callbackQueue.async { completion(.success(objects)) } diff --git a/Tests/ParseSwiftTests/ParseAnonymousAsyncTests.swift b/Tests/ParseSwiftTests/ParseAnonymousAsyncTests.swift index a7e1278b1..839d15199 100644 --- a/Tests/ParseSwiftTests/ParseAnonymousAsyncTests.swift +++ b/Tests/ParseSwiftTests/ParseAnonymousAsyncTests.swift @@ -90,7 +90,6 @@ class ParseAnonymousAsyncTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -118,7 +117,7 @@ class ParseAnonymousAsyncTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(isLinked) } @@ -128,7 +127,6 @@ class ParseAnonymousAsyncTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -156,7 +154,7 @@ class ParseAnonymousAsyncTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(isLinked) } diff --git a/Tests/ParseSwiftTests/ParseAnonymousCombineTests.swift b/Tests/ParseSwiftTests/ParseAnonymousCombineTests.swift index 014c916b3..aae43b682 100644 --- a/Tests/ParseSwiftTests/ParseAnonymousCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseAnonymousCombineTests.swift @@ -92,7 +92,6 @@ class ParseAnonymousCombineTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -126,7 +125,7 @@ class ParseAnonymousCombineTests: XCTestCase { XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseAnonymous.isLinked(with: user)) }) publisher.store(in: &subscriptions) @@ -141,7 +140,6 @@ class ParseAnonymousCombineTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -175,7 +173,7 @@ class ParseAnonymousCombineTests: XCTestCase { XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseAnonymous.isLinked(with: user)) }) publisher.store(in: &subscriptions) diff --git a/Tests/ParseSwiftTests/ParseAnonymousTests.swift b/Tests/ParseSwiftTests/ParseAnonymousTests.swift index 2344ff7b6..80409c895 100644 --- a/Tests/ParseSwiftTests/ParseAnonymousTests.swift +++ b/Tests/ParseSwiftTests/ParseAnonymousTests.swift @@ -129,7 +129,6 @@ class ParseAnonymousTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -156,7 +155,7 @@ class ParseAnonymousTests: XCTestCase { XCTAssertEqual(login1, currentUser) XCTAssertEqual(login1, userOnServer) XCTAssertEqual(login1.username, "hello") - XCTAssertEqual(login1.password, "world") + XCTAssertNil(login1.password) let isLinked = await login1.anonymous.isLinked() XCTAssertTrue(isLinked) } @@ -169,7 +168,6 @@ class ParseAnonymousTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -194,7 +192,7 @@ class ParseAnonymousTests: XCTestCase { let currentUser = try await User.current() XCTAssertEqual(currentUser, userOnServer) XCTAssertEqual(currentUser.username, "hello") - XCTAssertEqual(currentUser.password, "world") + XCTAssertNil(currentUser.password) let isLinked = await currentUser.anonymous.isLinked() XCTAssertTrue(isLinked) @@ -220,7 +218,6 @@ class ParseAnonymousTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -247,7 +244,7 @@ class ParseAnonymousTests: XCTestCase { XCTAssertEqual(login1, currentUser) XCTAssertEqual(login1, userOnServer) XCTAssertEqual(login1.username, "hello") - XCTAssertEqual(login1.password, "world") + XCTAssertNil(login1.password) XCTAssertTrue(ParseAnonymous.isLinked(with: login1)) } @@ -284,7 +281,7 @@ class ParseAnonymousTests: XCTestCase { let currentUser = try await User.current() XCTAssertEqual(signedInUser, currentUser) XCTAssertEqual(signedInUser.username, "hello") - XCTAssertEqual(signedInUser.password, "world") + XCTAssertNil(signedInUser.password) XCTAssertFalse(ParseAnonymous.isLinked(with: signedInUser)) } @@ -321,7 +318,7 @@ class ParseAnonymousTests: XCTestCase { let currentUser = try await User.current() XCTAssertEqual(signedInUser, currentUser) XCTAssertEqual(signedInUser.username, "hello") - XCTAssertEqual(signedInUser.password, "world") + XCTAssertNil(signedInUser.password) XCTAssertFalse(ParseAnonymous.isLinked(with: signedInUser)) } @@ -467,7 +464,7 @@ class ParseAnonymousTests: XCTestCase { case .success(let user): XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) case .failure(let error): XCTFail(error.localizedDescription) @@ -515,7 +512,7 @@ class ParseAnonymousTests: XCTestCase { case .success(let user): XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) case .failure(let error): XCTFail(error.localizedDescription) @@ -533,7 +530,6 @@ class ParseAnonymousTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -563,7 +559,7 @@ class ParseAnonymousTests: XCTestCase { case .success(let user): XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseAnonymous.isLinked(with: user)) case .failure(let error): XCTFail(error.localizedDescription) @@ -581,7 +577,6 @@ class ParseAnonymousTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -611,7 +606,7 @@ class ParseAnonymousTests: XCTestCase { case .success(let user): XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseAnonymous.isLinked(with: user)) case .failure(let error): XCTFail(error.localizedDescription) diff --git a/Tests/ParseSwiftTests/ParseAppleCombineTests.swift b/Tests/ParseSwiftTests/ParseAppleCombineTests.swift index 3dfaeedbd..777d53c6f 100644 --- a/Tests/ParseSwiftTests/ParseAppleCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseAppleCombineTests.swift @@ -98,7 +98,6 @@ class ParseAppleCombineTests: XCTestCase { // swiftlint:disable:this type_body_l var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.apple.__type: authData] @@ -140,7 +139,7 @@ class ParseAppleCombineTests: XCTestCase { // swiftlint:disable:this type_body_l XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { @@ -170,7 +169,6 @@ class ParseAppleCombineTests: XCTestCase { // swiftlint:disable:this type_body_l var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.apple.__type: authData] @@ -208,7 +206,7 @@ class ParseAppleCombineTests: XCTestCase { // swiftlint:disable:this type_body_l XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let updatedCurrentUser = try await User.current() diff --git a/Tests/ParseSwiftTests/ParseAppleTests.swift b/Tests/ParseSwiftTests/ParseAppleTests.swift index 580880123..22b47d034 100644 --- a/Tests/ParseSwiftTests/ParseAppleTests.swift +++ b/Tests/ParseSwiftTests/ParseAppleTests.swift @@ -108,7 +108,6 @@ class ParseAppleTests: XCTestCase { //: Convert the anonymous user to a real new user. var serverResponse = LoginSignupResponse() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -135,7 +134,6 @@ class ParseAppleTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") XCTAssertTrue(ParseAnonymous.isLinked(with: user)) } @@ -166,7 +164,6 @@ class ParseAppleTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.apple.__type: authData] @@ -198,7 +195,7 @@ class ParseAppleTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseApple.isLinked(with: user)) // Test stripping @@ -212,7 +209,6 @@ class ParseAppleTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.apple.__type: authData] @@ -240,7 +236,7 @@ class ParseAppleTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseApple.isLinked(with: user)) } @@ -331,7 +327,7 @@ class ParseAppleTests: XCTestCase { XCTAssertEqual(user.updatedAt, userOnServer.updatedAt) XCTAssertEqual(user.authData, userOnServer.authData) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) } @@ -367,7 +363,7 @@ class ParseAppleTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user.updatedAt, userOnServer.updatedAt) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) } diff --git a/Tests/ParseSwiftTests/ParseAuthenticationAsyncTests.swift b/Tests/ParseSwiftTests/ParseAuthenticationAsyncTests.swift index e57d8fe20..fbfb71674 100644 --- a/Tests/ParseSwiftTests/ParseAuthenticationAsyncTests.swift +++ b/Tests/ParseSwiftTests/ParseAuthenticationAsyncTests.swift @@ -145,7 +145,6 @@ class ParseAuthenticationAsyncTests: XCTestCase { let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() let type = TestAuth.__type serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [type: authData] @@ -172,7 +171,7 @@ class ParseAuthenticationAsyncTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertEqual(user.authData, serverResponse.authData) } diff --git a/Tests/ParseSwiftTests/ParseAuthenticationCombineTests.swift b/Tests/ParseSwiftTests/ParseAuthenticationCombineTests.swift index 4a15a5352..062dcff4f 100644 --- a/Tests/ParseSwiftTests/ParseAuthenticationCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseAuthenticationCombineTests.swift @@ -164,7 +164,6 @@ class ParseAuthenticationCombineTests: XCTestCase { let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() let type = TestAuth.__type serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [type: authData] @@ -201,7 +200,7 @@ class ParseAuthenticationCombineTests: XCTestCase { XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertEqual(user.authData, serverResponse.authData) Task { do { diff --git a/Tests/ParseSwiftTests/ParseFacebookCombineTests.swift b/Tests/ParseSwiftTests/ParseFacebookCombineTests.swift index 5cf85e280..e96230ed2 100644 --- a/Tests/ParseSwiftTests/ParseFacebookCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseFacebookCombineTests.swift @@ -113,7 +113,6 @@ class ParseFacebookCombineTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.facebook.__type: authData] @@ -151,7 +150,7 @@ class ParseFacebookCombineTests: XCTestCase { XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let currentUser = try await User.current() @@ -177,7 +176,6 @@ class ParseFacebookCombineTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.facebook.__type: authData] @@ -214,7 +212,7 @@ class ParseFacebookCombineTests: XCTestCase { XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let currentUser = try await User.current() @@ -240,7 +238,6 @@ class ParseFacebookCombineTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.facebook.__type: authData] @@ -282,7 +279,7 @@ class ParseFacebookCombineTests: XCTestCase { XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let currentUser = try await User.current() diff --git a/Tests/ParseSwiftTests/ParseFacebookTests.swift b/Tests/ParseSwiftTests/ParseFacebookTests.swift index 0c615358e..bca743a81 100644 --- a/Tests/ParseSwiftTests/ParseFacebookTests.swift +++ b/Tests/ParseSwiftTests/ParseFacebookTests.swift @@ -108,7 +108,6 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt //: Convert the anonymous user to a real new user. var serverResponse = LoginSignupResponse() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -135,7 +134,7 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseAnonymous.isLinked(with: user)) } @@ -213,7 +212,6 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.facebook.__type: authData] @@ -244,7 +242,7 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt let isLinked = await user.facebook.isLinked() XCTAssertTrue(isLinked) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) } @MainActor @@ -324,7 +322,7 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt let isLinked = await user.facebook.isLinked() XCTAssertTrue(isLinked) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) } @MainActor @@ -398,7 +396,7 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt XCTAssertFalse(isLinked) XCTAssertEqual(user.updatedAt, userOnServer.updatedAt) XCTAssertEqual(user.username, "hello") - XCTAssertNotNil(user.password) + XCTAssertNil(user.password) } @MainActor @@ -434,7 +432,7 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt XCTAssertFalse(isLinked) XCTAssertEqual(user.updatedAt, userOnServer.updatedAt) XCTAssertEqual(user.username, "hello") - XCTAssertNotNil(user.password) + XCTAssertNil(user.password) } @MainActor @@ -442,7 +440,6 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.facebook.__type: authData] @@ -471,7 +468,7 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt let isLinked = await user.facebook.isLinked() XCTAssertTrue(isLinked) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) } @MainActor @@ -517,7 +514,7 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt let isLinked = await user.facebook.isLinked() XCTAssertTrue(isLinked) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) } @MainActor @@ -526,7 +523,6 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.facebook.__type: authData] @@ -560,7 +556,7 @@ class ParseFacebookTests: XCTestCase { // swiftlint:disable:this type_body_lengt var isLinked = await user.facebook.isLinked() XCTAssertTrue(isLinked) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) // Test stripping let strippedUser = user.facebook.strip(currentUser) diff --git a/Tests/ParseSwiftTests/ParseGitHubCombineTests.swift b/Tests/ParseSwiftTests/ParseGitHubCombineTests.swift index f7dd652db..4ee1fdbe2 100644 --- a/Tests/ParseSwiftTests/ParseGitHubCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseGitHubCombineTests.swift @@ -113,7 +113,6 @@ class ParseGitHubCombineTests: XCTestCase { // swiftlint:disable:this type_body_ var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.github.__type: authData] @@ -150,7 +149,7 @@ class ParseGitHubCombineTests: XCTestCase { // swiftlint:disable:this type_body_ XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let current = try await User.current() @@ -178,7 +177,6 @@ class ParseGitHubCombineTests: XCTestCase { // swiftlint:disable:this type_body_ var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.github.__type: authData] @@ -216,7 +214,7 @@ class ParseGitHubCombineTests: XCTestCase { // swiftlint:disable:this type_body_ XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let current = try await User.current() diff --git a/Tests/ParseSwiftTests/ParseGitHubTests.swift b/Tests/ParseSwiftTests/ParseGitHubTests.swift index d1ce4b504..1d3fb2601 100644 --- a/Tests/ParseSwiftTests/ParseGitHubTests.swift +++ b/Tests/ParseSwiftTests/ParseGitHubTests.swift @@ -157,7 +157,6 @@ class ParseGitHubTests: XCTestCase { // swiftlint:disable:this type_body_length var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.github.__type: authData] @@ -187,7 +186,7 @@ class ParseGitHubTests: XCTestCase { // swiftlint:disable:this type_body_length XCTAssertTrue(isLinked) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) // Test stripping let strippedUser = user.github.strip(current) @@ -201,7 +200,6 @@ class ParseGitHubTests: XCTestCase { // swiftlint:disable:this type_body_length var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.github.__type: authData] @@ -231,7 +229,7 @@ class ParseGitHubTests: XCTestCase { // swiftlint:disable:this type_body_length XCTAssertTrue(isLinked) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) } @MainActor diff --git a/Tests/ParseSwiftTests/ParseGoogleCombineTests.swift b/Tests/ParseSwiftTests/ParseGoogleCombineTests.swift index 04cdefe73..e704649ab 100644 --- a/Tests/ParseSwiftTests/ParseGoogleCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseGoogleCombineTests.swift @@ -113,7 +113,6 @@ class ParseGoogleCombineTests: XCTestCase { // swiftlint:disable:this type_body_ var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.google.__type: authData] @@ -150,7 +149,7 @@ class ParseGoogleCombineTests: XCTestCase { // swiftlint:disable:this type_body_ XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let current = try await User.current() @@ -178,7 +177,6 @@ class ParseGoogleCombineTests: XCTestCase { // swiftlint:disable:this type_body_ var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.google.__type: authData] @@ -216,7 +214,7 @@ class ParseGoogleCombineTests: XCTestCase { // swiftlint:disable:this type_body_ XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let current = try await User.current() diff --git a/Tests/ParseSwiftTests/ParseGoogleTests.swift b/Tests/ParseSwiftTests/ParseGoogleTests.swift index 21e70e4d6..896d87495 100644 --- a/Tests/ParseSwiftTests/ParseGoogleTests.swift +++ b/Tests/ParseSwiftTests/ParseGoogleTests.swift @@ -171,7 +171,6 @@ class ParseGoogleTests: XCTestCase { // swiftlint:disable:this type_body_length var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.google.__type: authData] @@ -202,7 +201,7 @@ class ParseGoogleTests: XCTestCase { // swiftlint:disable:this type_body_length XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) // Test stripping let strippedUser = user.google.strip(currentUser) @@ -216,7 +215,6 @@ class ParseGoogleTests: XCTestCase { // swiftlint:disable:this type_body_length var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.google.__type: authData] @@ -246,7 +244,7 @@ class ParseGoogleTests: XCTestCase { // swiftlint:disable:this type_body_length XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) } @MainActor diff --git a/Tests/ParseSwiftTests/ParseInstagramCombineTests.swift b/Tests/ParseSwiftTests/ParseInstagramCombineTests.swift index b7bdf2bf8..97011556d 100644 --- a/Tests/ParseSwiftTests/ParseInstagramCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseInstagramCombineTests.swift @@ -110,7 +110,6 @@ class ParseInstagramCombineTests: XCTestCase { // swiftlint:disable:this type_bo var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.instagram.__type: authData] @@ -149,7 +148,7 @@ class ParseInstagramCombineTests: XCTestCase { // swiftlint:disable:this type_bo XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let currentUser = try await User.current() @@ -177,7 +176,6 @@ class ParseInstagramCombineTests: XCTestCase { // swiftlint:disable:this type_bo var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.instagram.__type: authData] @@ -216,7 +214,7 @@ class ParseInstagramCombineTests: XCTestCase { // swiftlint:disable:this type_bo XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let currentUser = try await User.current() diff --git a/Tests/ParseSwiftTests/ParseInstagramTests.swift b/Tests/ParseSwiftTests/ParseInstagramTests.swift index 09142a1bf..342ecb075 100644 --- a/Tests/ParseSwiftTests/ParseInstagramTests.swift +++ b/Tests/ParseSwiftTests/ParseInstagramTests.swift @@ -110,7 +110,6 @@ class ParseInstagramTests: XCTestCase { //: Convert the anonymous user to a real new user. var serverResponse = LoginSignupResponse() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -137,7 +136,7 @@ class ParseInstagramTests: XCTestCase { XCTAssertEqual(user, current) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseAnonymous.isLinked(with: user)) } @@ -177,7 +176,6 @@ class ParseInstagramTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.instagram.__type: authData] @@ -202,7 +200,7 @@ class ParseInstagramTests: XCTestCase { let user = try await User.instagram.login(id: "testing", accessToken: "access_token", apiURL: "apiURL") XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) let current = try await User.current() XCTAssertEqual(user, current) var isLinked = await user.instagram.isLinked() @@ -219,7 +217,6 @@ class ParseInstagramTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.instagram.__type: authData] @@ -246,7 +243,7 @@ class ParseInstagramTests: XCTestCase { "apiURL": "apiURL"]) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) let current = try await User.current() XCTAssertEqual(user, current) var isLinked = await user.instagram.isLinked() @@ -397,7 +394,7 @@ class ParseInstagramTests: XCTestCase { let user = try await User.instagram.login(id: "testing", accessToken: "access_token", apiURL: "apiURL") XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) let current = try await User.current() XCTAssertEqual(user, current) let isLinked = await user.instagram.isLinked() @@ -424,7 +421,7 @@ class ParseInstagramTests: XCTestCase { let user = try await User.instagram.link(id: "testing", accessToken: "access_token") XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) let current = try await User.current() XCTAssertEqual(user, current) let isLinked = await user.instagram.isLinked() diff --git a/Tests/ParseSwiftTests/ParseLDAPCombineTests.swift b/Tests/ParseSwiftTests/ParseLDAPCombineTests.swift index c7c0f26ea..79ef880d3 100644 --- a/Tests/ParseSwiftTests/ParseLDAPCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseLDAPCombineTests.swift @@ -110,7 +110,6 @@ class ParseLDAPCombineTests: XCTestCase { // swiftlint:disable:this type_body_le var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.ldap.__type: authData] @@ -147,7 +146,7 @@ class ParseLDAPCombineTests: XCTestCase { // swiftlint:disable:this type_body_le XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let current = try await User.current() @@ -176,7 +175,6 @@ class ParseLDAPCombineTests: XCTestCase { // swiftlint:disable:this type_body_le var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.ldap.__type: authData] @@ -214,7 +212,7 @@ class ParseLDAPCombineTests: XCTestCase { // swiftlint:disable:this type_body_le XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let current = try await User.current() diff --git a/Tests/ParseSwiftTests/ParseLDAPTests.swift b/Tests/ParseSwiftTests/ParseLDAPTests.swift index 414e8b5ff..70420d2c2 100644 --- a/Tests/ParseSwiftTests/ParseLDAPTests.swift +++ b/Tests/ParseSwiftTests/ParseLDAPTests.swift @@ -109,7 +109,6 @@ class ParseLDAPTests: XCTestCase { //: Convert the anonymous user to a real new user. var serverResponse = LoginSignupResponse() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -136,7 +135,6 @@ class ParseLDAPTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") XCTAssertTrue(ParseAnonymous.isLinked(with: user)) } @@ -164,7 +162,6 @@ class ParseLDAPTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.ldap.__type: authData] @@ -193,7 +190,7 @@ class ParseLDAPTests: XCTestCase { XCTAssertEqual(user, current) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) } @MainActor @@ -202,7 +199,6 @@ class ParseLDAPTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.ldap.__type: authData] @@ -230,7 +226,7 @@ class ParseLDAPTests: XCTestCase { XCTAssertTrue(isLinked) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) } @MainActor @@ -339,7 +335,7 @@ class ParseLDAPTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user.updatedAt, userOnServer.updatedAt) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) } @@ -370,7 +366,7 @@ class ParseLDAPTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user.updatedAt, userOnServer.updatedAt) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) } diff --git a/Tests/ParseSwiftTests/ParseLinkedInCombineTests.swift b/Tests/ParseSwiftTests/ParseLinkedInCombineTests.swift index 6d452bf14..a01f1f0fa 100644 --- a/Tests/ParseSwiftTests/ParseLinkedInCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseLinkedInCombineTests.swift @@ -108,7 +108,6 @@ class ParseLinkedInCombineTests: XCTestCase { // swiftlint:disable:this type_bod var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.linkedin.__type: authData] @@ -144,7 +143,7 @@ class ParseLinkedInCombineTests: XCTestCase { // swiftlint:disable:this type_bod XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseLinkedIn.isLinked(with: user)) }) publisher.store(in: ¤t) @@ -159,7 +158,6 @@ class ParseLinkedInCombineTests: XCTestCase { // swiftlint:disable:this type_bod var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.linkedin.__type: authData] @@ -195,7 +193,7 @@ class ParseLinkedInCombineTests: XCTestCase { // swiftlint:disable:this type_bod XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseLinkedIn.isLinked(with: user)) }) publisher.store(in: ¤t) diff --git a/Tests/ParseSwiftTests/ParseLinkedInTests.swift b/Tests/ParseSwiftTests/ParseLinkedInTests.swift index a7d6bf1e6..7ab43b4ea 100644 --- a/Tests/ParseSwiftTests/ParseLinkedInTests.swift +++ b/Tests/ParseSwiftTests/ParseLinkedInTests.swift @@ -162,7 +162,6 @@ class ParseLinkedInTests: XCTestCase { // swiftlint:disable:this type_body_lengt var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.linkedin.__type: authData] @@ -191,7 +190,7 @@ class ParseLinkedInTests: XCTestCase { // swiftlint:disable:this type_body_lengt XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) var currentLinkedUser = await user.linkedin.isLinked() XCTAssertTrue(currentLinkedUser) @@ -207,7 +206,6 @@ class ParseLinkedInTests: XCTestCase { // swiftlint:disable:this type_body_lengt var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.linkedin.__type: authData] @@ -236,7 +234,7 @@ class ParseLinkedInTests: XCTestCase { // swiftlint:disable:this type_body_lengt XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) let currentLinkedUser = await user.linkedin.isLinked() XCTAssertTrue(currentLinkedUser) } diff --git a/Tests/ParseSwiftTests/ParseSpotifyCombineTests.swift b/Tests/ParseSwiftTests/ParseSpotifyCombineTests.swift index 400d643bb..2766d21b2 100644 --- a/Tests/ParseSwiftTests/ParseSpotifyCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseSpotifyCombineTests.swift @@ -95,7 +95,6 @@ class ParseSpotifyCombineTests: XCTestCase { // swiftlint:disable:this type_body var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.spotify.__type: authData] @@ -132,7 +131,7 @@ class ParseSpotifyCombineTests: XCTestCase { // swiftlint:disable:this type_body XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { @@ -162,7 +161,6 @@ class ParseSpotifyCombineTests: XCTestCase { // swiftlint:disable:this type_body var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.spotify.__type: authData] @@ -200,7 +198,7 @@ class ParseSpotifyCombineTests: XCTestCase { // swiftlint:disable:this type_body XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) Task { do { let currentUser = try await User.current() diff --git a/Tests/ParseSwiftTests/ParseSpotifyTests.swift b/Tests/ParseSwiftTests/ParseSpotifyTests.swift index f7bb40d8b..7b39b55e6 100644 --- a/Tests/ParseSwiftTests/ParseSpotifyTests.swift +++ b/Tests/ParseSwiftTests/ParseSpotifyTests.swift @@ -110,7 +110,6 @@ class ParseSpotifyTests: XCTestCase { //: Convert the anonymous user to a real new user. var serverResponse = LoginSignupResponse() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -137,7 +136,7 @@ class ParseSpotifyTests: XCTestCase { XCTAssertEqual(user, current) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseAnonymous.isLinked(with: user)) } @@ -210,7 +209,7 @@ class ParseSpotifyTests: XCTestCase { XCTAssertTrue(isLinked) XCTAssertEqual(user.authData, userOnServer.authData) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) // Test stripping @@ -254,7 +253,7 @@ class ParseSpotifyTests: XCTestCase { XCTAssertTrue(isLinked) XCTAssertEqual(user.authData, userOnServer.authData) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) } @@ -299,7 +298,7 @@ class ParseSpotifyTests: XCTestCase { XCTAssertTrue(isLinked) XCTAssertEqual(user.authData, userOnServer.authData) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) } @@ -332,7 +331,7 @@ class ParseSpotifyTests: XCTestCase { let isLinked = ParseSpotify.isLinked(with: current) XCTAssertTrue(isLinked) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) } diff --git a/Tests/ParseSwiftTests/ParseTwitterCombineTests.swift b/Tests/ParseSwiftTests/ParseTwitterCombineTests.swift index 0dbed9cf3..546d9d78a 100644 --- a/Tests/ParseSwiftTests/ParseTwitterCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseTwitterCombineTests.swift @@ -93,7 +93,6 @@ class ParseTwitterCombineTests: XCTestCase { // swiftlint:disable:this type_body var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.twitter.__type: authData] @@ -132,7 +131,7 @@ class ParseTwitterCombineTests: XCTestCase { // swiftlint:disable:this type_body XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseTwitter.isLinked(with: user)) }) publisher.store(in: ¤t) @@ -147,7 +146,6 @@ class ParseTwitterCombineTests: XCTestCase { // swiftlint:disable:this type_body var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.twitter.__type: authData] @@ -189,7 +187,7 @@ class ParseTwitterCombineTests: XCTestCase { // swiftlint:disable:this type_body XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseTwitter.isLinked(with: user)) }) publisher.store(in: ¤t) diff --git a/Tests/ParseSwiftTests/ParseTwitterTests.swift b/Tests/ParseSwiftTests/ParseTwitterTests.swift index a787d7a38..efa038664 100644 --- a/Tests/ParseSwiftTests/ParseTwitterTests.swift +++ b/Tests/ParseSwiftTests/ParseTwitterTests.swift @@ -110,7 +110,6 @@ class ParseTwitterTests: XCTestCase { //: Convert the anonymous user to a real new user. var serverResponse = LoginSignupResponse() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.anonymous.__type: authData] @@ -137,7 +136,7 @@ class ParseTwitterTests: XCTestCase { XCTAssertEqual(user, currentUser) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseAnonymous.isLinked(with: user)) } @@ -185,7 +184,6 @@ class ParseTwitterTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.twitter.__type: authData] @@ -216,7 +214,7 @@ class ParseTwitterTests: XCTestCase { XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) let currentUser = try await User.current() XCTAssertEqual(user, currentUser) var isLinked = ParseTwitter.isLinked(with: currentUser) @@ -234,7 +232,6 @@ class ParseTwitterTests: XCTestCase { var serverResponse = LoginSignupResponse() let authData = ParseAnonymous.AuthenticationKeys.id.makeDictionary() serverResponse.username = "hello" - serverResponse.password = "world" serverResponse.objectId = "yarr" serverResponse.sessionToken = "myToken" serverResponse.authData = [serverResponse.twitter.__type: authData] @@ -267,7 +264,7 @@ class ParseTwitterTests: XCTestCase { let user = try await User.twitter.login(authData: twitterAuthData) XCTAssertEqual(user, userOnServer) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) let currentUser = try await User.current() XCTAssertEqual(user, currentUser) let isLinked = ParseTwitter.isLinked(with: currentUser) @@ -395,7 +392,7 @@ class ParseTwitterTests: XCTestCase { let currentUser = try await User.current() XCTAssertEqual(user, currentUser) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseTwitter.isLinked(with: user)) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) } @@ -426,7 +423,7 @@ class ParseTwitterTests: XCTestCase { let currentUser = try await User.current() XCTAssertEqual(user, currentUser) XCTAssertEqual(user.username, "hello") - XCTAssertEqual(user.password, "world") + XCTAssertNil(user.password) XCTAssertTrue(ParseTwitter.isLinked(with: user)) XCTAssertFalse(ParseAnonymous.isLinked(with: user)) } diff --git a/Tests/ParseSwiftTests/ParseUserCombineTests.swift b/Tests/ParseSwiftTests/ParseUserCombineTests.swift index 6e15018aa..3e88be460 100644 --- a/Tests/ParseSwiftTests/ParseUserCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseUserCombineTests.swift @@ -734,24 +734,7 @@ class ParseUserCombineTests: XCTestCase { // swiftlint:disable:this type_body_le XCTAssertNotNil(currentUser.objectId) XCTAssertNotNil(currentUser.customKey) XCTAssertNil(currentUser.ACL) - - Task { - do { - let userFromStorage = try await BaseParseUser.current() - XCTAssertNotNil(userFromStorage.createdAt) - XCTAssertNotNil(userFromStorage.updatedAt) - XCTAssertNotNil(userFromStorage.email) - XCTAssertNotNil(userFromStorage.username) - XCTAssertNil(userFromStorage.password) - XCTAssertNotNil(userFromStorage.objectId) - XCTAssertNil(userFromStorage.ACL) - } catch { - XCTFail(error.localizedDescription) - } - DispatchQueue.main.async { - expectation2.fulfill() - } - } + expectation2.fulfill() }) publisher.store(in: &subscriptions) #if compiler(>=5.8.0) && !os(Linux) && !os(Android) && !os(Windows) diff --git a/Tests/ParseSwiftTests/ParseUserTests.swift b/Tests/ParseSwiftTests/ParseUserTests.swift index 7995837ac..cf7855110 100644 --- a/Tests/ParseSwiftTests/ParseUserTests.swift +++ b/Tests/ParseSwiftTests/ParseUserTests.swift @@ -1054,17 +1054,6 @@ class ParseUserTests: XCTestCase { // swiftlint:disable:this type_body_length XCTAssertNotNil(currentUser.objectId) XCTAssertNotNil(currentUser.customKey) XCTAssertNil(currentUser.ACL) - - let userFromStorage = try await BaseParseUser.current() - - XCTAssertNotNil(userFromStorage.createdAt) - XCTAssertNotNil(userFromStorage.updatedAt) - XCTAssertNotNil(userFromStorage.email) - XCTAssertNotNil(userFromStorage.username) - XCTAssertNil(userFromStorage.password) - XCTAssertNotNil(userFromStorage.objectId) - _ = try await BaseParseUser.sessionToken() - XCTAssertNil(userFromStorage.ACL) } @MainActor @@ -1493,6 +1482,35 @@ class ParseUserTests: XCTestCase { // swiftlint:disable:this type_body_length @MainActor func testSaveAndUpdateCurrentUser() async throws { + try await login() + MockURLProtocol.removeAll() + + let newUsername = "stop" + let current = try await User.current() + var serverResponse = current + serverResponse.username = newUsername + serverResponse.createdAt = nil + serverResponse.updatedAt = current.updatedAt?.addingTimeInterval(+300) + + MockURLProtocol.mockRequests { _ in + do { + let encoded = try serverResponse.getEncoder().encode(serverResponse, skipKeys: .none) + return MockURLResponse(data: encoded, statusCode: 200) + } catch { + return nil + } + } + + let user = current + .set(\.username, to: newUsername) + let saved = try await user.save() + XCTAssertEqual(saved.objectId, serverResponse.objectId) + XCTAssertEqual(saved.updatedAt, serverResponse.updatedAt) + XCTAssertEqual(saved.username, serverResponse.username) + } + + @MainActor + func testSaveAndUpdateCurrentUserNoChange() async throws { try await userSignUp() let user = try await User.current() XCTAssertNotNil(user.objectId)