Skip to content

Commit

Permalink
Adds more keychain tests for request credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmitchell committed Sep 14, 2015
1 parent 5ee1e55 commit 71a13c1
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions ThunderRequestTests/ThunderRequest-KeychainTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,58 @@ class ThunderRequest_KeychainTests: XCTestCase {
XCTAssertNotNil(pulledCredential.username, "Credential username was retrieved as nil")
XCTAssertNotNil(pulledCredential.password, "Credential password was retrieved as nil")
XCTAssertNotNil(pulledCredential.credential, "Credential credential was retrieved as nil")

TSCRequestCredential.deleteCredentialWithIdentifier("credential")

let deletedCredential = TSCRequestCredential.retrieveCredentialWithIdentifier("credential")

XCTAssertNil(deletedCredential, "Credential was not deleted correctly from the keychain")
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.

}

func testAuthTokenCredentialToKeychain() {

let credential = TSCRequestCredential(authorizationToken: "TOKEN")

TSCRequestCredential.storeCredential(credential, withIdentifier: "credential")

let pulledCredential = TSCRequestCredential.retrieveCredentialWithIdentifier("credential")

XCTAssertNotNil(pulledCredential, "Credential was not saved or pulled from keychain")
XCTAssertNotNil(pulledCredential.authorizationToken, "Credential token was retrieved as nil")

TSCRequestCredential.deleteCredentialWithIdentifier("credential")

let deletedCredential = TSCRequestCredential.retrieveCredentialWithIdentifier("credential")

XCTAssertNil(deletedCredential, "Credential was not deleted correctly from the keychain")
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.

}

func testOAuth2CredentialToKeychain() {

let credential = TSCOAuth2Credential(authorizationToken: "TOKEN", refreshToken: "REFRESHTOKEN", expiryDate: NSDate(timeIntervalSinceNow: 24))

TSCOAuth2Credential.storeCredential(credential, withIdentifier: "credential")

let pulledCredential = TSCOAuth2Credential.retrieveCredentialWithIdentifier("credential")

XCTAssertNotNil(pulledCredential, "Credential was not saved or pulled from keychain")
XCTAssertNotNil(pulledCredential.authorizationToken, "Credential token was retrieved as nil")
XCTAssertNotNil(pulledCredential.refreshToken, "Credential refresh token was retrieved as nil")
XCTAssertNotNil(pulledCredential.expirationDate, "Credential expiry date was retrieved as nil")

TSCRequestCredential.deleteCredentialWithIdentifier("credential")

let deletedCredential = TSCRequestCredential.retrieveCredentialWithIdentifier("credential")

XCTAssertNil(deletedCredential, "Credential was not deleted correctly from the keychain")
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.

}
}

0 comments on commit 71a13c1

Please sign in to comment.