-
Notifications
You must be signed in to change notification settings - Fork 24
chore: multibackend service test - WPB-19855 #3549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
91abb53
d160241
74456d2
b939c28
fff8ceb
5abd353
19b00c3
42cc522
f3f0879
66b9799
bb94ab9
539336b
3ac4995
eb62831
1f7b7fc
1837096
46af4f7
78be4f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,9 @@ | |
|
|
||
| import Foundation | ||
| import WireFoundation | ||
|
|
||
|
Check warning on line 21 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift
|
||
| class AuthenticationAPIV0: AuthenticationAPI, VersionedAPI { | ||
|
|
||
|
Check warning on line 23 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift
|
||
| let networkService: any NetworkServiceProtocol | ||
|
|
||
| init(networkService: any NetworkServiceProtocol) { | ||
|
|
@@ -192,18 +192,18 @@ | |
| .parse(code: response.statusCode, data: data) | ||
| } | ||
|
|
||
| func getActivationCode(forEmail email: String) async throws -> (code: String, key: String) { | ||
| func getActivationCode(forEmail email: String, basicAuth: String) async throws -> (code: String, key: String) { | ||
| let path = "/i/users/activation-code?email=\(email)" | ||
| let auth = ProcessInfo.processInfo.environment["BASIC_AUTH"]! | ||
|
|
||
| let request = try URLRequestBuilder(path: path) | ||
| .withMethod(.get) | ||
| .addingHeader(field: "Authorization", value: "Basic \(auth)") | ||
| .addingHeader(field: "Authorization", value: "Basic \(basicAuth)") | ||
| .build() | ||
|
|
||
| let (data, response) = try await networkService.executeRequest(request) | ||
|
|
||
| guard | ||
|
Check warning on line 205 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift
|
||
| let responseURL = response.url, | ||
|
Check warning on line 206 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift
|
||
| let responseHeaders = response.allHeaderFields as? [String: String] | ||
| else { | ||
| throw AuthenticationAPIError.invalidResponse | ||
|
|
@@ -228,7 +228,7 @@ | |
| .withMethod(.post) | ||
| .withBody(body, contentType: .json) | ||
| .build() | ||
|
|
||
|
Check warning on line 231 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift
|
||
| let (data, response) = try await networkService.executeRequest(request) | ||
|
|
||
| guard | ||
|
|
@@ -260,11 +260,11 @@ | |
| .withMethod(.post) | ||
| .withBody(body, contentType: .json) | ||
| .build() | ||
|
|
||
|
Check warning on line 263 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift
|
||
| let (data, response) = try await networkService.executeRequest(request) | ||
|
|
||
|
Check warning on line 265 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift
|
||
| try ResponseParser() | ||
| .success(code: .ok) | ||
|
Check warning on line 267 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift
|
||
| .failure(code: .badRequest, label: "bad-request", error: AuthenticationAPIError.invalidEmail) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // | ||
| // Wire | ||
| // Copyright (C) 2025 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 Foundation | ||
| import WireNetwork | ||
|
|
||
| public enum BackendContext { | ||
| static var current: BackendTarget = .staging | ||
|
|
||
| static var backendEnvironment: BackendEnvironment { | ||
| switch current { | ||
| case .staging: | ||
| .staging | ||
| case .anta: | ||
| .anta | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public enum BackendTarget { | ||
| case staging | ||
| case anta | ||
|
|
||
| var domainInfo: String { | ||
| switch self { | ||
| case .staging: | ||
| "staging.zinfra.io" | ||
| case .anta: | ||
| "anta.wire.link" | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.