From e29805bc98bbf4f520e041e57460a19b772546ca Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Fri, 9 Apr 2021 15:50:32 -0400 Subject: [PATCH] Use new Uphold sandbox URL --- .../api/brave_extensions_api_client.cc | 2 +- .../brave_extensions_api_client_unittest.cc | 2 +- .../bat/ledger/internal/uphold/uphold_util.h | 2 +- .../internal/uphold/uphold_util_unittest.cc | 169 ++++++++++-------- 4 files changed, 93 insertions(+), 82 deletions(-) diff --git a/browser/extensions/api/brave_extensions_api_client.cc b/browser/extensions/api/brave_extensions_api_client.cc index 59b97501d2f1..d4c3b8e68e61 100644 --- a/browser/extensions/api/brave_extensions_api_client.cc +++ b/browser/extensions/api/brave_extensions_api_client.cc @@ -18,7 +18,7 @@ bool BraveExtensionsAPIClient::ShouldHideBrowserNetworkRequest( const WebRequestInfo& request) const { const url::Origin origin = url::Origin::Create(request.url); const base::StringPiece path = request.url.path_piece(); - if (((origin.DomainIs("sandbox.uphold.com") || + if (((origin.DomainIs("wallet-sandbox.uphold.com") || origin.DomainIs("uphold.com")) && base::StartsWith(path, "/authorize/", base::CompareCase::INSENSITIVE_ASCII)) || diff --git a/browser/extensions/api/brave_extensions_api_client_unittest.cc b/browser/extensions/api/brave_extensions_api_client_unittest.cc index a6095af8b0cc..77bcad514432 100644 --- a/browser/extensions/api/brave_extensions_api_client_unittest.cc +++ b/browser/extensions/api/brave_extensions_api_client_unittest.cc @@ -41,7 +41,7 @@ TEST_F(BraveExtensionsAPIClientTests, IsBraveProtectedUrlUphold) { WebRequestInfo blocked1( create_request_params("https://uphold.com/authorize/1234")); WebRequestInfo blocked2(create_request_params( - "https://sandbox.uphold.com/authorize/1234?state=abcd")); + "https://wallet-sandbox.uphold.com/authorize/1234?state=abcd")); WebRequestInfo blocked3( create_request_params("https://api.uphold.com/oauth2/token")); ASSERT_TRUE(ShouldHideBrowserNetworkRequest(blocked1)); diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_util.h b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_util.h index ddbf3eebb38f..428737d6a31a 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_util.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_util.h @@ -17,7 +17,7 @@ class LedgerImpl; namespace uphold { -const char kUrlStaging[] = "https://sandbox.uphold.com"; +const char kUrlStaging[] = "https://wallet-sandbox.uphold.com"; const char kUrlProduction[] = "https://uphold.com"; const char kFeeAddressStaging[] = "1b2b466f-5c15-49bf-995e-c91777d3da93"; const char kFeeAddressProduction[] = "b01e8c55-5004-4761-9e4b-01ec13e25c92"; diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_util_unittest.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_util_unittest.cc index b53a43d7678a..3673e829cf6c 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_util_unittest.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_util_unittest.cc @@ -93,13 +93,14 @@ TEST_F(UpholdUtilTest, GetAuthorizeUrl) { // staging ledger::_environment = type::Environment::STAGING; result = uphold::GetAuthorizeUrl("rdfdsfsdfsdf", true); - ASSERT_EQ(result, - "https://sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID - "?scope=accounts:read " - "accounts:write cards:read cards:write user:read " - "transactions:deposit transactions:read " - "transactions:transfer:application transactions:transfer:others" - "&intention=kyc&state=rdfdsfsdfsdf"); + ASSERT_EQ( + result, + "https://wallet-sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID + "?scope=accounts:read " + "accounts:write cards:read cards:write user:read " + "transactions:deposit transactions:read " + "transactions:transfer:application transactions:transfer:others" + "&intention=kyc&state=rdfdsfsdfsdf"); // production ledger::_environment = type::Environment::PRODUCTION; @@ -116,13 +117,14 @@ TEST_F(UpholdUtilTest, GetAuthorizeUrl) { // staging ledger::_environment = type::Environment::STAGING; result = uphold::GetAuthorizeUrl("rdfdsfsdfsdf", false); - ASSERT_EQ(result, - "https://sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID - "?scope=accounts:read " - "accounts:write cards:read cards:write user:read " - "transactions:deposit transactions:read " - "transactions:transfer:application transactions:transfer:others" - "&intention=login&state=rdfdsfsdfsdf"); + ASSERT_EQ( + result, + "https://wallet-sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID + "?scope=accounts:read " + "accounts:write cards:read cards:write user:read " + "transactions:deposit transactions:read " + "transactions:transfer:application transactions:transfer:others" + "&intention=login&state=rdfdsfsdfsdf"); } TEST_F(UpholdUtilTest, GetAddUrl) { @@ -138,8 +140,9 @@ TEST_F(UpholdUtilTest, GetAddUrl) { // staging ledger::_environment = type::Environment::STAGING; result = uphold::GetAddUrl("9324i5i32459i"); - ASSERT_EQ(result, - "https://sandbox.uphold.com/dashboard/cards/9324i5i32459i/add"); + ASSERT_EQ( + result, + "https://wallet-sandbox.uphold.com/dashboard/cards/9324i5i32459i/add"); } TEST_F(UpholdUtilTest, GetWithdrawUrl) { @@ -155,8 +158,9 @@ TEST_F(UpholdUtilTest, GetWithdrawUrl) { // staging ledger::_environment = type::Environment::STAGING; result = uphold::GetWithdrawUrl("9324i5i32459i"); - ASSERT_EQ(result, - "https://sandbox.uphold.com/dashboard/cards/9324i5i32459i/use"); + ASSERT_EQ( + result, + "https://wallet-sandbox.uphold.com/dashboard/cards/9324i5i32459i/use"); } TEST_F(UpholdUtilTest, GetSecondStepVerify) { @@ -171,7 +175,7 @@ TEST_F(UpholdUtilTest, GetSecondStepVerify) { ledger::_environment = type::Environment::STAGING; result = uphold::GetSecondStepVerify(); ASSERT_EQ(result, - "https://sandbox.uphold.com/signup/step2" + "https://wallet-sandbox.uphold.com/signup/step2" "?application_id=" UPHOLD_STAGING_CLIENT_ID "&intention=kyc"); } @@ -183,17 +187,18 @@ TEST_F(UpholdUtilTest, GetWallet) { ASSERT_TRUE(!result); const std::string wallet = R"({ - "account_url":"https://sandbox.uphold.com/dashboard", - "add_url":"https://sandbox.uphold.com/dashboard/cards/asadasdasd/add", + "account_url":"https://wallet-sandbox.uphold.com/dashboard", + "add_url":"https://wallet-sandbox.uphold.com/dashboard/cards/asadasdasd/add", "address":"2323dff2ba-d0d1-4dfw-8e56-a2605bcaf4af", "fees":{}, - "login_url":"https://sandbox.uphold.com/authorize/4c2b665ca060d", + "login_url":"https://wallet-sandbox.uphold.com/authorize/4c2b665ca060d", "one_time_string":"1F747AE0A708E47ED7E650BF1856B5A4EF7E36833BDB1158A108F8", "status":2, "token":"4c80232r219c30cdf112208890a32c7e00", "user_name":"test", "verify_url":"", - "withdraw_url":"https://sandbox.uphold.com/dashboard/cards/asadasdasd/use" + "withdraw_url": + "https://wallet-sandbox.uphold.com/dashboard/cards/asadasdasd/use" })"; ON_CALL(*mock_ledger_client_, GetEncryptedStringState(state::kWalletUphold)) @@ -232,39 +237,41 @@ TEST_F(UpholdUtilTest, GenerateLinks) { auto result = uphold::GenerateLinks(wallet->Clone()); ASSERT_EQ(result->add_url, ""); ASSERT_EQ(result->withdraw_url, ""); - ASSERT_EQ(result->verify_url, - "https://sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID - "?scope=accounts:read " - "accounts:write cards:read cards:write user:read " - "transactions:deposit transactions:read " - "transactions:transfer:application transactions:transfer:others" - "&intention=kyc&state="); - ASSERT_EQ(result->account_url, "https://sandbox.uphold.com/dashboard"); + ASSERT_EQ( + result->verify_url, + "https://wallet-sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID + "?scope=accounts:read " + "accounts:write cards:read cards:write user:read " + "transactions:deposit transactions:read " + "transactions:transfer:application transactions:transfer:others" + "&intention=kyc&state="); + ASSERT_EQ(result->account_url, "https://wallet-sandbox.uphold.com/dashboard"); // Connected wallet->status = type::WalletStatus::CONNECTED; result = uphold::GenerateLinks(wallet->Clone()); ASSERT_EQ(result->add_url, - "https://sandbox.uphold.com/dashboard/cards/123123123124234234234/add"); + "https://wallet-sandbox.uphold.com/dashboard/cards/" + "123123123124234234234/add"); ASSERT_EQ(result->withdraw_url, - "https://sandbox.uphold.com/signup/step2" + "https://wallet-sandbox.uphold.com/signup/step2" "?application_id=" UPHOLD_STAGING_CLIENT_ID "&intention=kyc"); ASSERT_EQ(result->verify_url, - "https://sandbox.uphold.com/signup/step2" + "https://wallet-sandbox.uphold.com/signup/step2" "?application_id=" UPHOLD_STAGING_CLIENT_ID "&intention=kyc"); - ASSERT_EQ(result->account_url, "https://sandbox.uphold.com/dashboard"); + ASSERT_EQ(result->account_url, "https://wallet-sandbox.uphold.com/dashboard"); // Verified wallet->status = type::WalletStatus::VERIFIED; result = uphold::GenerateLinks(wallet->Clone()); - ASSERT_EQ( - result->add_url, - "https://sandbox.uphold.com/dashboard/cards/123123123124234234234/add"); - ASSERT_EQ( - result->withdraw_url, - "https://sandbox.uphold.com/dashboard/cards/123123123124234234234/use"); + ASSERT_EQ(result->add_url, + "https://wallet-sandbox.uphold.com/dashboard/cards/" + "123123123124234234234/add"); + ASSERT_EQ(result->withdraw_url, + "https://wallet-sandbox.uphold.com/dashboard/cards/" + "123123123124234234234/use"); ASSERT_EQ(result->verify_url, ""); - ASSERT_EQ(result->account_url, "https://sandbox.uphold.com/dashboard"); + ASSERT_EQ(result->account_url, "https://wallet-sandbox.uphold.com/dashboard"); // Disconnected Non-Verified wallet->status = type::WalletStatus::DISCONNECTED_NOT_VERIFIED; @@ -273,40 +280,41 @@ TEST_F(UpholdUtilTest, GenerateLinks) { ASSERT_EQ(result->withdraw_url, ""); ASSERT_EQ( result->verify_url, - "https://sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID + "https://wallet-sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID "?scope=accounts:read accounts:write cards:read cards:write user:read " "transactions:deposit transactions:read " "transactions:transfer:application transactions:transfer:others" "&intention=kyc&state="); - ASSERT_EQ(result->account_url, "https://sandbox.uphold.com/dashboard"); + ASSERT_EQ(result->account_url, "https://wallet-sandbox.uphold.com/dashboard"); // Disconnected Verified wallet->status = type::WalletStatus::DISCONNECTED_VERIFIED; result = uphold::GenerateLinks(wallet->Clone()); ASSERT_EQ(result->add_url, ""); ASSERT_EQ(result->withdraw_url, ""); - ASSERT_EQ(result->verify_url, - "https://sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID - "?scope=accounts:read " - "accounts:write cards:read cards:write user:read " - "transactions:deposit transactions:read " - "transactions:transfer:application transactions:transfer:others" - "&intention=kyc&state="); - ASSERT_EQ(result->account_url, "https://sandbox.uphold.com/dashboard"); + ASSERT_EQ( + result->verify_url, + "https://wallet-sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID + "?scope=accounts:read " + "accounts:write cards:read cards:write user:read " + "transactions:deposit transactions:read " + "transactions:transfer:application transactions:transfer:others" + "&intention=kyc&state="); + ASSERT_EQ(result->account_url, "https://wallet-sandbox.uphold.com/dashboard"); // Pending wallet->status = type::WalletStatus::PENDING; result = uphold::GenerateLinks(wallet->Clone()); ASSERT_EQ(result->add_url, - "https://sandbox.uphold.com/signup/step2" + "https://wallet-sandbox.uphold.com/signup/step2" "?application_id=" UPHOLD_STAGING_CLIENT_ID "&intention=kyc"); ASSERT_EQ(result->withdraw_url, - "https://sandbox.uphold.com/signup/step2" + "https://wallet-sandbox.uphold.com/signup/step2" "?application_id=" UPHOLD_STAGING_CLIENT_ID "&intention=kyc"); ASSERT_EQ(result->verify_url, - "https://sandbox.uphold.com/signup/step2" + "https://wallet-sandbox.uphold.com/signup/step2" "?application_id=" UPHOLD_STAGING_CLIENT_ID "&intention=kyc"); - ASSERT_EQ(result->account_url, "https://sandbox.uphold.com/dashboard"); + ASSERT_EQ(result->account_url, "https://wallet-sandbox.uphold.com/dashboard"); } TEST_F(UpholdUtilTest, GenerateVerifyLink) { @@ -318,19 +326,20 @@ TEST_F(UpholdUtilTest, GenerateVerifyLink) { // Not connected wallet->status = type::WalletStatus::NOT_CONNECTED; auto result = uphold::GenerateVerifyLink(wallet->Clone()); - ASSERT_EQ(result, - "https://sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID - "?scope=accounts:read " - "accounts:write cards:read cards:write user:read " - "transactions:deposit transactions:read " - "transactions:transfer:application transactions:transfer:others" - "&intention=kyc&state=123123123124234234234"); + ASSERT_EQ( + result, + "https://wallet-sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID + "?scope=accounts:read " + "accounts:write cards:read cards:write user:read " + "transactions:deposit transactions:read " + "transactions:transfer:application transactions:transfer:others" + "&intention=kyc&state=123123123124234234234"); // Connected wallet->status = type::WalletStatus::CONNECTED; result = uphold::GenerateVerifyLink(wallet->Clone()); ASSERT_EQ(result, - "https://sandbox.uphold.com/signup/step2" + "https://wallet-sandbox.uphold.com/signup/step2" "?application_id=" UPHOLD_STAGING_CLIENT_ID "&intention=kyc"); // Verified @@ -341,30 +350,32 @@ TEST_F(UpholdUtilTest, GenerateVerifyLink) { // Disconnected Non-Verified wallet->status = type::WalletStatus::DISCONNECTED_NOT_VERIFIED; result = uphold::GenerateVerifyLink(wallet->Clone()); - ASSERT_EQ(result, - "https://sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID - "?scope=accounts:read " - "accounts:write cards:read cards:write user:read " - "transactions:deposit transactions:read " - "transactions:transfer:application transactions:transfer:others" - "&intention=kyc&state=123123123124234234234"); + ASSERT_EQ( + result, + "https://wallet-sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID + "?scope=accounts:read " + "accounts:write cards:read cards:write user:read " + "transactions:deposit transactions:read " + "transactions:transfer:application transactions:transfer:others" + "&intention=kyc&state=123123123124234234234"); // Disconnected Verified wallet->status = type::WalletStatus::DISCONNECTED_VERIFIED; result = uphold::GenerateVerifyLink(wallet->Clone()); - ASSERT_EQ(result, - "https://sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID - "?scope=accounts:read " - "accounts:write cards:read cards:write user:read " - "transactions:deposit transactions:read " - "transactions:transfer:application transactions:transfer:others" - "&intention=kyc&state=123123123124234234234"); + ASSERT_EQ( + result, + "https://wallet-sandbox.uphold.com/authorize/" UPHOLD_STAGING_CLIENT_ID + "?scope=accounts:read " + "accounts:write cards:read cards:write user:read " + "transactions:deposit transactions:read " + "transactions:transfer:application transactions:transfer:others" + "&intention=kyc&state=123123123124234234234"); // Pending wallet->status = type::WalletStatus::PENDING; result = uphold::GenerateVerifyLink(wallet->Clone()); ASSERT_EQ(result, - "https://sandbox.uphold.com/signup/step2" + "https://wallet-sandbox.uphold.com/signup/step2" "?application_id=" UPHOLD_STAGING_CLIENT_ID "&intention=kyc"); }