-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/ci-snapshots-WPB-14950
- Loading branch information
Showing
133 changed files
with
4,359 additions
and
726 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
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
124 changes: 124 additions & 0 deletions
124
WireAPI/Tests/WireAPITests/APIs/AccountsAPI/AccountsAPITests.swift
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,124 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2024 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
|
||
import XCTest | ||
|
||
@testable import WireAPI | ||
@testable import WireAPISupport | ||
|
||
final class AccountsAPITests: XCTestCase { | ||
|
||
private var apiSnapshotHelper: APIServiceSnapshotHelper<any AccountsAPI>! | ||
|
||
// MARK: - Setup | ||
|
||
override func setUp() { | ||
apiSnapshotHelper = APIServiceSnapshotHelper<any AccountsAPI> { apiService, apiVersion in | ||
AccountsAPIBuilder(apiService: apiService) | ||
.makeAPI(for: apiVersion) | ||
|
||
} | ||
} | ||
|
||
override func tearDown() { | ||
apiSnapshotHelper = nil | ||
} | ||
|
||
// MARK: - Request generation | ||
|
||
func testUpgradeToTeam_V0_To_V6() async throws { | ||
// Given | ||
let apiService = MockAPIServiceProtocol() | ||
let builder = AccountsAPIBuilder(apiService: apiService) | ||
|
||
for apiVersion in [APIVersion.v0, .v1, .v2, .v3, .v4, .v5, .v6] { | ||
let sut = builder.makeAPI(for: apiVersion) | ||
|
||
// Then | ||
await XCTAssertThrowsErrorAsync(AccountsAPIError.unsupportedEndpointForAPIVersion) { | ||
try await sut.upgradeToTeam(teamName: Scaffolding.teamName) | ||
} | ||
} | ||
} | ||
|
||
func testUpgradeToTeam_Request_Generation_V7_Onwards() async throws { | ||
// Given | ||
let apiVersions = APIVersion.v7.andNextVersions | ||
|
||
// Then | ||
Check failure on line 63 in WireAPI/Tests/WireAPITests/APIs/AccountsAPI/AccountsAPITests.swift GitHub Actions / Test ResultsAccountsAPITests.testUpgradeToTeam_Request_Generation_V7_Onwards() failed
|
||
try await apiSnapshotHelper.verifyRequest(for: apiVersions) { sut in | ||
// When | ||
_ = try await sut.upgradeToTeam(teamName: Scaffolding.teamName) | ||
} | ||
} | ||
|
||
// MARK: - Response handling | ||
|
||
func testUpgradeToTeam_Response_Handling_V7_Success() async throws { | ||
// Given | ||
let apiService = MockAPIServiceProtocol.withResponses([ | ||
(.ok, "UpgradeToTeamSuccessResponse") | ||
]) | ||
|
||
let sut = AccountsAPIV7(apiService: apiService) | ||
|
||
// When | ||
let response = try await sut.upgradeToTeam(teamName: Scaffolding.teamName) | ||
|
||
// Then | ||
XCTAssertEqual(response, UpgradedAccountTeam(teamId: Scaffolding.teamID, teamName: Scaffolding.teamName)) | ||
} | ||
|
||
func testUpgradeToTeam_Response_Handling_V7_User_Already_In_A_Team() async throws { | ||
// Given | ||
let apiService = MockAPIServiceProtocol.withResponses([ | ||
(.forbidden, "UpgradeToTeamErrorResponse_UserAlreadyInATeam") | ||
]) | ||
|
||
let sut = AccountsAPIV7(apiService: apiService) | ||
|
||
// Then | ||
await XCTAssertThrowsErrorAsync(AccountsAPIError.userAlreadyInATeam) { | ||
// When | ||
try await sut.upgradeToTeam(teamName: Scaffolding.teamName) | ||
} | ||
} | ||
|
||
func testUpgradeToTeam_Response_Handling_V7_User_Not_Found() async throws { | ||
// Given | ||
let apiService = MockAPIServiceProtocol.withResponses([ | ||
(.notFound, "UpgradeToTeamErrorResponse_UserNotFound") | ||
]) | ||
|
||
let sut = AccountsAPIV7(apiService: apiService) | ||
|
||
// Then | ||
await XCTAssertThrowsErrorAsync(AccountsAPIError.userNotFound) { | ||
// When | ||
try await sut.upgradeToTeam(teamName: Scaffolding.teamName) | ||
} | ||
} | ||
|
||
} | ||
|
||
private enum Scaffolding { | ||
|
||
static let teamName = "iOS Team" | ||
static let teamID = UUID(uuidString: "66dc3593-4c3a-49e8-b5c3-d3d908bd7403")! | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...ireAPITests/APIs/AccountsAPI/Resources/UpgradeToTeamErrorResponse_UserAlreadyInATeam.json
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,5 @@ | ||
{ | ||
"code": 403, | ||
"label": "user-already-in-a-team", | ||
"message": "Switching teams is not allowed" | ||
} |
5 changes: 5 additions & 0 deletions
5
...ests/WireAPITests/APIs/AccountsAPI/Resources/UpgradeToTeamErrorResponse_UserNotFound.json
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,5 @@ | ||
{ | ||
"code": 404, | ||
"label": "not-found", | ||
"message": "User not found" | ||
} |
4 changes: 4 additions & 0 deletions
4
WireAPI/Tests/WireAPITests/APIs/AccountsAPI/Resources/UpgradeToTeamSuccessResponse.json
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,4 @@ | ||
{ | ||
"team_id": "66dc3593-4c3a-49e8-b5c3-d3d908bd7403", | ||
"team_name": "iOS Team" | ||
} |
5 changes: 5 additions & 0 deletions
5
...shots__/AccountsAPITests/testUpgradeToTeam_Request_Generation_V7_Onwards.request-0-v7.txt
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,5 @@ | ||
curl \ | ||
--request POST \ | ||
--header "Content-Type: application/json" \ | ||
--data "{\"name\":\"iOS Team\",\"icon\":\"default\"}" \ | ||
"upgrade-personal-to-team" |
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 |
---|---|---|
|
@@ -11,5 +11,6 @@ | |
"subconv": "subconversation", | ||
"data": { | ||
"text": "message" | ||
} | ||
}, | ||
"time": "2024-06-04T15:03:07.598Z" | ||
} |
Oops, something went wrong.