Skip to content

Commit

Permalink
PM-12242 Fixed iconsURL for EU and also fixed send share URL for unit…
Browse files Browse the repository at this point in the history
…edStates
  • Loading branch information
fedemkr committed Sep 17, 2024
1 parent e58e73a commit 7d37d9d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ extension EnvironmentUrlData {
api: URL(string: "https://api.bitwarden.eu")!,
base: URL(string: "https://vault.bitwarden.eu")!,
events: URL(string: "https://events.bitwarden.eu")!,
icons: URL(string: "https://icons.bitwarden.net")!,
icons: URL(string: "https://icons.bitwarden.eu")!,
identity: URL(string: "https://identity.bitwarden.eu")!,
notifications: URL(string: "https://notifications.bitwarden.eu")!,
webVault: URL(string: "https://vault.bitwarden.eu")!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EnvironmentUrlDataTests: XCTestCase {
api: URL(string: "https://api.bitwarden.eu")!,
base: URL(string: "https://vault.bitwarden.eu")!,
events: URL(string: "https://events.bitwarden.eu")!,
icons: URL(string: "https://icons.bitwarden.net")!,
icons: URL(string: "https://icons.bitwarden.eu")!,
identity: URL(string: "https://identity.bitwarden.eu")!,
notifications: URL(string: "https://notifications.bitwarden.eu")!,
webVault: URL(string: "https://vault.bitwarden.eu")!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class EnvironmentUrlsTests: BitwardenTestCase {
apiURL: URL(string: "https://api.bitwarden.eu")!,
baseURL: URL(string: "https://vault.bitwarden.eu")!,
eventsURL: URL(string: "https://events.bitwarden.eu")!,
iconsURL: URL(string: "https://icons.bitwarden.net")!,
iconsURL: URL(string: "https://icons.bitwarden.eu")!,
identityURL: URL(string: "https://identity.bitwarden.eu")!,
importItemsURL: URL(string: "https://vault.bitwarden.eu/#/tools/import")!,
recoveryCodeURL: URL(string: "https://vault.bitwarden.eu/#/recover-2fa")!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class EnvironmentServiceTests: XCTestCase {

XCTAssertEqual(subject.apiURL, URL(string: "https://api.bitwarden.eu"))
XCTAssertEqual(subject.eventsURL, URL(string: "https://events.bitwarden.eu"))
XCTAssertEqual(subject.iconsURL, URL(string: "https://icons.bitwarden.net"))
XCTAssertEqual(subject.iconsURL, URL(string: "https://icons.bitwarden.eu"))
XCTAssertEqual(subject.identityURL, URL(string: "https://identity.bitwarden.eu"))
XCTAssertEqual(subject.importItemsURL, URL(string: "https://vault.bitwarden.eu/#/tools/import"))
XCTAssertEqual(subject.region, .europe)
Expand Down
8 changes: 6 additions & 2 deletions BitwardenShared/Core/Tools/Repositories/SendRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,12 @@ class DefaultSendRepository: SendRepository {

func shareURL(for sendView: SendView) async throws -> URL? {
guard let accessId = sendView.accessId, let key = sendView.key else { return nil }
let sharePath = "/\(accessId)/\(key)"
let url = URL(string: environmentService.sendShareURL.absoluteString.appending(sharePath))
let sharePath = "\(accessId)/\(key)"
var sendShareUrlString = environmentService.sendShareURL.absoluteString
if !sendShareUrlString.hasSuffix("#") {
sendShareUrlString = sendShareUrlString.appending("/")
}
let url = URL(string: sendShareUrlString.appending(sharePath))
return url
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,20 @@ class SendRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
/// `shareURL()` successfully generates a share url for the send view.
func test_shareURL() async throws {
let sendView = SendView.fixture(accessId: "ACCESS_ID", key: "KEY")
environmentService.webVaultURL = .example
let url = try await subject.shareURL(for: sendView)

XCTAssertEqual(url?.absoluteString, "https://example.com/#/send/ACCESS_ID/KEY")
}

/// `shareURL()` successfully generates a share url for the send view when the `sendShareURL` ends with a "#".
func test_shareURL_poundSignSuffix() async throws {
let sendView = SendView.fixture(accessId: "ACCESS_ID", key: "KEY")
environmentService.sendShareURL = URL(string: "https://send.bitwarden.com/#")!
let url = try await subject.shareURL(for: sendView)

XCTAssertEqual(url?.absoluteString, "https://send.bitwarden.com/#ACCESS_ID/KEY")
}

/// `updateSend()` successfully encrypts the send view and uses the send service to update it.
func test_updateSend() async throws {
let sendResult = Send.fixture(id: "SEND_ID")
Expand Down

0 comments on commit 7d37d9d

Please sign in to comment.