Commit 1a7cf3b3 authored by Jose Blaya's avatar Jose Blaya
Browse files

Unit tests

parent 9ab0f8a4
This diff is collapsed.
......@@ -41,9 +41,9 @@
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0EBFFFD41F693F800009D4F4"
BuildableName = "PIALibrary.framework"
BlueprintName = "PIALibrary-iOS"
BlueprintIdentifier = "0EE78B0B1F818A32002E4CDD"
BuildableName = "PIALibraryHost-iOS.app"
BlueprintName = "PIALibraryHost-iOS"
ReferencedContainer = "container:PIALibrary.xcodeproj">
</BuildableReference>
</CodeCoverageTargets>
......
......@@ -133,7 +133,7 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
/// :nodoc:
public func loadLocalJSON(fromJSON jsonData: Data) {
return delegate.load(fromJSON: jsonData)
return delegate.loadLocalJSON(fromJSON: jsonData)
}
/// :nodoc:
......
......@@ -70,6 +70,8 @@ class AccountInfoTests: XCTestCase {
public func testRenewableProduct() {
Client.providers.accountProvider.logout(nil)
let factory = MockProviders()
let expLogin = expectation(description: "login")
let credentials = Credentials(username: "p0000000", password: "foobarbogus")
......
......@@ -101,7 +101,7 @@ class AccountTests: XCTestCase {
}
XCTAssert(factory.accountProvider.isLoggedIn)
XCTAssertNotNil(factory.accountProvider.currentUser)
print("Logged in with: \(factory.accountProvider.currentUser!)")
print("Logged in with: \(factory.accountProvider.currentUser)")
expLogin.fulfill()
}
waitForExpectations(timeout: 5.0, handler: nil)
......
//
// DIPTokenKeychainTests.swift
// PIALibrary
//
// Created by Jose Blaya on 16/10/2020.
// Copyright © 2020 Private Internet Access, Inc.
//
// This file is part of the Private Internet Access iOS Client.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import XCTest
@testable import PIALibrary
class DIPTokenKeychainTests: XCTestCase {
override class func setUp() {
Client.database.secure.removeDIPTokens()
}
func testAddDipToken() throws {
Client.database.secure.setDIPToken("token_1")
XCTAssertTrue(Client.database.secure.dipTokens()?.count == 1)
}
func testAddMultipleDipTokens() throws {
Client.database.secure.setDIPToken("token_1")
Client.database.secure.setDIPToken("token_2")
Client.database.secure.setDIPToken("token_3")
XCTAssertTrue(Client.database.secure.dipTokens()?.count == 3)
}
func testAddSameDipToken() throws {
Client.database.secure.setDIPToken("token_1")
Client.database.secure.setDIPToken("token_1")
XCTAssertTrue(Client.database.secure.dipTokens()?.count == 1)
}
func testRemoveAllTokens() throws {
Client.database.secure.setDIPToken("token_1")
Client.database.secure.setDIPToken("token_2")
Client.database.secure.setDIPToken("token_3")
XCTAssertTrue(Client.database.secure.dipTokens()?.count == 3)
Client.database.secure.removeDIPTokens()
XCTAssertTrue(Client.database.secure.dipTokens() == nil)
}
func testRemoveSpecificTokens() throws {
Client.database.secure.setDIPToken("token_1")
Client.database.secure.setDIPToken("token_2")
Client.database.secure.setDIPToken("token_3")
XCTAssertTrue(Client.database.secure.dipTokens()?.count == 3)
Client.database.secure.remove("token_2")
XCTAssertTrue(Client.database.secure.dipTokens()![0] == "token_1")
XCTAssertTrue(Client.database.secure.dipTokens()![1] == "token_3")
}
}
......@@ -43,15 +43,8 @@ class EndpointManagerTests: XCTestCase {
}
func testLegacy() throws {
Client.configuration.setServerNetworks(to: .legacy) //Set legacy as current network
let endpoints = EndpointManager.shared.availableEndpoints()
XCTAssertTrue(endpoints.count == 2)
}
func testGEN4Endpoints() throws {
Client.configuration.setServerNetworks(to: .gen4) //Set gen4 as current network
ServersPinger.shared.ping(withDestinations: Client.providers.serverProvider.currentServers)
eventually(timeout: 10.0) {
......
This diff is collapsed.
......@@ -114,6 +114,6 @@ SPEC CHECKSUMS:
TunnelKit: 1733ed87934deb57edc7aa5f4b25185bf302a7d4
TweetNacl: 3abf4d1d2082b0114e7a67410e300892448951e6
PODFILE CHECKSUM: 7b505471eb03240fadcb14de86defe1d40d92822
PODFILE CHECKSUM: 4e30427f8560a243bbdac8f09b026767a23a302a
COCOAPODS: 1.9.3
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment