-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add iOS test for connecting to API via bridges
- Loading branch information
1 parent
446ef2b
commit 26630f9
Showing
19 changed files
with
584 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
// | ||
// MullvadVPNUITests.xcconfig | ||
// MullvadVPN | ||
// | ||
// Created by Niklas Berglund on 2024-01-10. | ||
// Copyright © 2024 Mullvad VPN AB. All rights reserved. | ||
// | ||
#include "Base.xcconfig" | ||
|
||
// Pin code of the iOS device under test | ||
MULLVAD_IOS_DEVICE_PIN_CODE = | ||
IOS_DEVICE_PIN_CODE = | ||
|
||
// Ad serving domain used when testing ad blocking. Not that we are assuming there's an HTTP server running on the host. | ||
MULLVAD_AD_SERVING_DOMAIN = | ||
// UUID to identify test runs. Should be unique per test device. Generate with for example uuidgen on macOS. | ||
TEST_DEVICE_IDENTIFIER_UUID = | ||
|
||
// Mullvad accounts used by UI tests | ||
MULLVAD_NO_TIME_ACCOUNT_NUMBER = | ||
MULLVAD_HAS_TIME_ACCOUNT_NUMBER = | ||
MULLVAD_FIVE_WIREGUARD_KEYS_ACCOUNT_NUMBER = | ||
NO_TIME_ACCOUNT_NUMBER = | ||
HAS_TIME_ACCOUNT_NUMBER = | ||
FIVE_WIREGUARD_KEYS_ACCOUNT_NUMBER = | ||
|
||
// Ad serving domain used when testing ad blocking. Note that we are assuming there's an HTTP server running on the host. | ||
AD_SERVING_DOMAIN = vpnlist.to | ||
|
||
// Base URL for the firewall API, Note that // will be treated as a comment, therefor you need to insert a ${} between the slashes for example http:/${}/8.8.8.8 | ||
FIREWALL_API_BASE_URL = http:/${}/8.8.8.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// ConnectivityTests.swift | ||
// MullvadVPNUITests | ||
// | ||
// Created by Niklas Berglund on 2024-01-18. | ||
// Copyright © 2024 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Network | ||
import XCTest | ||
|
||
class ConnectivityTests: LoggedOutUITestCase { | ||
let firewallAPIClient = FirewallAPIClient() | ||
|
||
override func setUpWithError() throws { | ||
super.setUp() | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
super.tearDown() | ||
firewallAPIClient.removeRules() | ||
} | ||
|
||
/// Verifies that the app still functions when API has been blocked | ||
func testAPIConnectionViaBridges() throws { | ||
let app = XCUIApplication() | ||
app.launch() | ||
|
||
try Networking.verifyCanAccessAPI() // Just to make sure there's no old firewall rule still active | ||
firewallAPIClient.createRule(try FirewallRule.makeBlockAPIAccessFirewallRule()) | ||
try Networking.verifyCannotAccessAPI() | ||
|
||
LoginPage(app) | ||
.tapAccountNumberTextField() | ||
.enterText(self.hasTimeAccountNumber) | ||
.tapAccountNumberSubmitButton() | ||
|
||
// After creating firewall rule first login attempt might fail. One more attempt is allowed since the app is cycling between two methods. | ||
if isLoggedIn() { | ||
LoginPage(app) | ||
.verifySuccessIconShown() | ||
.verifyDeviceLabelShown() | ||
} else { | ||
LoginPage(app) | ||
.verifyFailIconShown() | ||
.tapAccountNumberSubmitButton() | ||
.verifySuccessIconShown() | ||
.verifyDeviceLabelShown() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.