Skip to content

Commit

Permalink
Merge branch 'lantean/1187-updates-magic-link-endpoints' into lantean…
Browse files Browse the repository at this point in the history
…/adjusting-copy
  • Loading branch information
jleandroperez committed Jul 16, 2024
2 parents 83f7103 + df598b0 commit a40ea75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion SimplenoteTests/LoginRemoteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LoginRemoteTests: XCTestCase {
/// Verify
let body: Dictionary<String, String> = try XCTUnwrap(urlSession.lastRequest?.decodeHtmlBody())

XCTAssertEqual(body["email"], "[email protected]")
XCTAssertEqual(body["username"], "[email protected]")
XCTAssertEqual(body["auth_code"], "5678")

XCTAssertEqual(expectedResponse, decodedResponse)
Expand Down
9 changes: 5 additions & 4 deletions SimplenoteTests/MagicLinkAuthenticatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ final class MagicLinkAuthenticatorTests: XCTestCase {

func testMagicLinkURLResultsInLoginConfirmationRequest() async throws {
let expectation = expectation(description: "LoginConfirmationRequest")
loginRemote.onLoginConfirmationRequest = { (authKey, authCode) in
loginRemote.onLoginConfirmationRequest = { (email, authCode) in
XCTAssertEqual(authCode, MagicLinkTestConstants.expectedCode)
XCTAssertEqual(authKey, MagicLinkTestConstants.expectedKey)
XCTAssertEqual(email, MagicLinkTestConstants.expectedUsername)

expectation.fulfill()

Expand Down Expand Up @@ -64,6 +64,7 @@ private enum MagicLinkTestConstants {
static let expectedSyncToken = "12345678"
static let expectedKey = "1234"
static let expectedCode = "5678"
static let sampleValidURL = URL(string: "simplenotemac://login?auth_key=\(expectedKey)&auth_code=\(expectedCode)")!
static let sampleInvalidURL = URL(string: "simplenotemac://login?auth_key=&auth_code=")!
static let encodedUsername = expectedUsername.data(using: .utf8)!.base64EncodedString()
static let sampleValidURL = URL(string: "simplenotemac://login?email=\(encodedUsername)&auth_code=\(expectedCode)")!
static let sampleInvalidURL = URL(string: "simplenotemac://login?email=&auth_code=")!
}
2 changes: 1 addition & 1 deletion SimplenoteTests/MockLoginRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation
class MockLoginRemote: LoginRemoteProtocol {
var lastLoginRequestEmail: String?

var onLoginConfirmationRequest: ((_ authKey: String, _ authCode: String) -> LoginConfirmationResponse)?
var onLoginConfirmationRequest: ((_ email: String, _ authCode: String) -> LoginConfirmationResponse)?

func requestLoginEmail(email: String) async throws {
lastLoginRequestEmail = email
Expand Down

0 comments on commit a40ea75

Please sign in to comment.