Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/duckduckgo/iOS into fcap…
Browse files Browse the repository at this point in the history
…pelli/breakage_report_improvements

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	DuckDuckGo/BrokenSiteInfo.swift
  • Loading branch information
federicocappelli committed Nov 16, 2023
2 parents 0352c8c + 78a1066 commit 5b6693b
Show file tree
Hide file tree
Showing 70 changed files with 38,583 additions and 444 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ jobs:
restore-keys: |
${{ runner.os }}-spm-
# Using Xcode 15 as the alpha build uses iOS 17 APIs
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_$(<.xcode-version).app/Contents/Developer
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app/Contents/Developer

- name: Prepare fastlane
run: bundle install
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/sync-end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,23 @@ jobs:
env: |
CODE=${{ steps.sync-recovery-code.outputs.recovery-code }}
- name: Create Asana task when workflow failed
if: ${{ failure() }}
run: |
curl -s "https://app.asana.com/api/1.0/tasks" \
--header "Accept: application/json" \
--header "Authorization: Bearer ${{ secrets.ASANA_ACCESS_TOKEN }}" \
--header "Content-Type: application/json" \
--data ' { "data": { "name": "GH Workflow Failure - Sync End to end tests", "workspace": "${{ vars.GH_ASANA_WORKSPACE_ID }}", "projects": [ "${{ vars.GH_ASANA_IOS_APP_PROJECT_ID }}" ], "notes" : "The end to end workflow has failed. See https://github.com/duckduckgo/iOS/actions/runs/${{ github.run_id }}" } }'
- name: Upload logs when workflow failed
uses: actions/upload-artifact@v3
if: failure()
with:
name: BuildLogs
path: |
xcodebuild.log
DerivedData/Logs/Test/*.xcresult
retention-days: 7


16 changes: 7 additions & 9 deletions .maestro/shared/sync_create.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
appId: com.duckduckgo.mobile.ios
---

- assertVisible: Sync
- tapOn: Sync
- assertVisible: Sync
- tapOn: "0"
- assertVisible: Turn on Sync?
- tapOn: Turn on Sync
- tapOn: Sync Another Device
- tapOn: Show QR Code
- assertVisible: "Go to Settings > Sync in the DuckDuckGo App on a different device and scan this QR code to sync."
- assertVisible: Sync & Back Up
- tapOn: Sync & Back Up
- assertVisible: Sync & Back Up
- tapOn: Start Sync & Back Up
- assertVisible: All Set!
- tapOn: Next
- assertVisible: Save Recovery Code?
2 changes: 1 addition & 1 deletion .maestro/shared/sync_delete.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
appId: com.duckduckgo.mobile.ios
---

- assertVisible: Sync
- assertVisible: Sync & Back Up
- scroll
- tapOn:
point: 50%,91% # TODO: Revisit after new setup flow has been implemented.
Expand Down
6 changes: 2 additions & 4 deletions .maestro/sync_tests/01_create_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ tags:


# Clean up
- tapOn: Back
- tapOn: Cancel
- tapOn: Not Now
- assertVisible: Sync
- assertVisible: Sync & Back Up
- runFlow:
file: ../shared/sync_delete.yaml
file: ../shared/sync_delete.yaml
17 changes: 7 additions & 10 deletions .maestro/sync_tests/02_login_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,22 @@ tags:
file: ../shared/sync_create.yaml

# Copy Sync Code and Log Out
- tapOn: Back
- tapOn: Cancel
- assertVisible: Save Recovery Key
- tapOn: Copy Key
- tapOn: Copy Code
- tapOn: Not Now
- tapOn: "1"
- assertVisible: Sync & Back Up
- tapOn: Turn Off Sync & Back Up
- assertVisible: Turn Off Sync?
- tapOn: Remove

# Login
- tapOn: "0"
- tapOn: Recover Your Synced Data
- tapOn: Manually Enter Code
- assertVisible: Sync & Back Up
- tapOn: Enter Text Code
- tapOn: Paste
- assertVisible: Device Synced!
- tapOn: Next
- tapOn: Not Now

# Clean up
- assertVisible: Sync
- assertVisible: Sync & Back Up
- runFlow:
file: ../shared/sync_delete.yaml
file: ../shared/sync_delete.yaml
21 changes: 11 additions & 10 deletions .maestro/sync_tests/03_recover_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ tags:
- tapOn:
id: searchEntry
- inputText: ${CODE}
- longPressOn:
id: searchEntry
- repeat:
while:
notVisible: "Select All"
commands:
- tapOn:
id: searchEntry
- tapOn: Select All
- tapOn: Cut
- tapOn:
Expand All @@ -35,14 +39,11 @@ tags:
- tapOn: Settings
- runFlow:
file: ../shared/set_internal_user.yaml
- assertVisible: Sync
- tapOn: Sync
- assertVisible: Sync
- tapOn: "0"
- assertVisible: Turn on Sync?
- tapOn: Recover Your Synced Data
- assertVisible: Scan QR Code
- tapOn: Manually Enter Code
- assertVisible: Sync & Back Up
- tapOn: Sync & Back Up
- assertVisible: Sync & Back up
- tapOn: Recover Your Data
- tapOn: Enter Text Code
- tapOn: Paste
- assertVisible: Device Synced!
- tapOn: Next
Expand Down
25 changes: 10 additions & 15 deletions .maestro/sync_tests/04_sync_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ tags:
- tapOn:
id: searchEntry
- inputText: ${CODE}
- longPressOn:
id: searchEntry
- runFlow:
when:
visible:
text: searchEntry
- repeat:
while:
notVisible: "Select All"
commands:
- tapOn: searchEntry
- tapOn:
id: searchEntry
- tapOn: Select All
- tapOn: Cut
- tapOn:
Expand All @@ -86,14 +84,11 @@ tags:
- tapOn: Settings
- runFlow:
file: ../shared/set_internal_user.yaml
- assertVisible: Sync
- tapOn: Sync
- assertVisible: Sync
- tapOn: "0"
- assertVisible: Turn on Sync?
- tapOn: Recover Your Synced Data
- assertVisible: Scan QR Code
- tapOn: Manually Enter Code
- assertVisible: Sync & Back Up
- tapOn: Sync & Back Up
- assertVisible: Sync & Back up
- tapOn: Recover Your Data
- tapOn: Enter Text Code
- tapOn: Paste
- assertVisible: Device Synced!
- tapOn: Next
Expand Down
2 changes: 2 additions & 0 deletions Core/AppDeepLinkSchemes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public enum AppDeepLinkSchemes: String, CaseIterable {

case addFavorite = "ddgAddFavorite"

case openVPN = "ddgOpenVPN"

public var url: URL {
URL(string: rawValue + "://")!
}
Expand Down
9 changes: 5 additions & 4 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ extension Pixel {
case networkProtectionClientFailedToEncodeRegisterKeyRequest
case networkProtectionClientFailedToFetchRegisteredServers
case networkProtectionClientFailedToParseRegisteredServersResponse
case networkProtectionClientFailedToFetchLocations
case networkProtectionClientFailedToParseLocationsResponse
case networkProtectionClientFailedToEncodeRedeemRequest
case networkProtectionClientInvalidInviteCode
case networkProtectionClientFailedToRedeemInviteCode
Expand Down Expand Up @@ -360,9 +362,6 @@ extension Pixel {
case remoteMessageSecondaryActionClicked
case remoteMessageSheet

// MARK: Return user measurement
case returnUser

// MARK: debug pixels
case dbCrashDetected

Expand Down Expand Up @@ -814,6 +813,9 @@ extension Pixel.Event {
case .networkProtectionClientFailedToFetchRegisteredServers: return "m_netp_backend_api_error_failed_to_fetch_registered_servers"
case .networkProtectionClientFailedToParseRegisteredServersResponse:
return "m_netp_backend_api_error_parsing_device_registration_response_failed"
case .networkProtectionClientFailedToFetchLocations: return "m_netp_backend_api_error_failed_to_fetch_locations"
case .networkProtectionClientFailedToParseLocationsResponse:
return "m_netp_backend_api_error_parsing_locations_response_failed"
case .networkProtectionClientFailedToEncodeRedeemRequest: return "m_netp_backend_api_error_encoding_redeem_request_body_failed"
case .networkProtectionClientInvalidInviteCode: return "m_netp_backend_api_error_invalid_invite_code"
case .networkProtectionClientFailedToRedeemInviteCode: return "m_netp_backend_api_error_failed_to_redeem_invite_code"
Expand Down Expand Up @@ -1002,7 +1004,6 @@ extension Pixel.Event {

case .compilationFailed: return "m_d_compilation_failed"
// MARK: - Return user measurement
case .returnUser: return "m_return_user"
case .debugReturnUserAddATB: return "m_debug_return_user_add_atb"
case .debugReturnUserReadATB: return "m_debug_return_user_read_atb"
case .debugReturnUserUpdateATB: return "m_debug_return_user_update_atb"
Expand Down
31 changes: 0 additions & 31 deletions Core/ReturnUserMeasurement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ class KeychainReturnUserMeasurement: ReturnUserMeasurement {
}

func installCompletedWithATB(_ atb: Atb) {
if let oldATB = readSecureATB() {
sendReturnUserMeasurement(oldATB, atb.version)
}
writeSecureATB(atb.version)
}

Expand Down Expand Up @@ -88,34 +85,6 @@ class KeychainReturnUserMeasurement: ReturnUserMeasurement {

}

private func readSecureATB() -> String? {
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: Self.SecureATBKeychainName,
kSecReturnData as String: kCFBooleanTrue!,
kSecMatchLimit as String: kSecMatchLimitOne
]

var dataTypeRef: AnyObject?
let status: OSStatus = SecItemCopyMatching(query as CFDictionary, &dataTypeRef)
if ![errSecSuccess, errSecItemNotFound].contains(status) {
fireDebugPixel(.debugReturnUserReadATB, errorCode: status)
}

if let data = dataTypeRef as? Data {
return String(data: data, encoding: .utf8)
}

return nil
}

private func sendReturnUserMeasurement(_ oldATB: String, _ newATB: String) {
Pixel.fire(pixel: .returnUser, withAdditionalParameters: [
PixelParameters.returnUserOldATB: oldATB,
PixelParameters.returnUserNewATB: newATB
])
}

private func fireDebugPixel(_ event: Pixel.Event, errorCode: OSStatus) {
Pixel.fire(pixel: event, withAdditionalParameters: [
PixelParameters.returnUserErrorCode: "\(errorCode)"
Expand Down
6 changes: 6 additions & 0 deletions Core/UserDefaults+NetworkProtection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ public extension UserDefaults {
}
}

public enum NetworkProtectionUserDefaultKeys {

public static let lastSelectedServer = "com.duckduckgo.network-protection.last-selected-server"

}

#endif
Loading

0 comments on commit 5b6693b

Please sign in to comment.