Skip to content

Commit

Permalink
Merge pull request #4379 from brave/uphold-scope
Browse files Browse the repository at this point in the history
Adds cc scope for uphold
  • Loading branch information
NejcZdovc committed Jan 22, 2020
2 parents f8b641d + 59b6b23 commit 970d3c4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ std::string GetVerifyUrl(const std::string& state) {

return base::StringPrintf(
"%s/authorize/%s"
"?scope=cards:read cards:write user:read transactions:read "
"?scope="
"accounts:read "
"accounts:write "
"cards:read "
"cards:write "
"user:read "
"transactions:deposit "
"transactions:read "
"transactions:transfer:application "
"transactions:transfer:others&intention=kyc&"
"transactions:transfer:others"
"&intention=kyc&"
"state=%s",
url.c_str(),
id.c_str(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,22 @@ TEST(UpholdUtilTest, GetVerifyUrl) {
std::string result = braveledger_uphold::GetVerifyUrl("rdfdsfsdfsdf");
ASSERT_EQ(result,
"https://uphold.com/authorize/"
"6d8d9473ed20be627f71ed46e207f40c004c5b1a?scope=cards:read cards:write "
"user:read transactions:read transactions:transfer:application "
"transactions:transfer:others&intention=kyc&state=rdfdsfsdfsdf");
"6d8d9473ed20be627f71ed46e207f40c004c5b1a?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");

// staging
ledger::_environment = ledger::Environment::STAGING;
result = braveledger_uphold::GetVerifyUrl("rdfdsfsdfsdf");
ASSERT_EQ(result,
"https://sandbox.uphold.com/authorize/"
"4c2b665ca060d912fec5c735c734859a06118cc8?scope=cards:read cards:write "
"user:read transactions:read transactions:transfer:application "
"transactions:transfer:others&intention=kyc&state=rdfdsfsdfsdf");
"4c2b665ca060d912fec5c735c734859a06118cc8?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");
}

TEST(UpholdUtilTest, GetAddUrl) {
Expand Down Expand Up @@ -202,9 +206,11 @@ TEST(UpholdUtilTest, GenerateLinks) {
ASSERT_EQ(result->withdraw_url, "");
ASSERT_EQ(result->verify_url,
"https://sandbox.uphold.com/authorize/4c2b665ca060d912fec5c735c734859a06"
"118cc8?scope=cards:read cards:write user:read transactions:read "
"transactions:transfer:application transactions:transfer:others&"
"intention=kyc&state=");
"118cc8?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");

// Connected
Expand Down Expand Up @@ -237,7 +243,9 @@ TEST(UpholdUtilTest, GenerateLinks) {
ASSERT_EQ(result->withdraw_url, "");
ASSERT_EQ(result->verify_url,
"https://sandbox.uphold.com/authorize/4c2b665ca060d912fec5c735c734859a0"
"6118cc8?scope=cards:read cards:write user:read transactions:read "
"6118cc8?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");
Expand All @@ -249,7 +257,9 @@ TEST(UpholdUtilTest, GenerateLinks) {
ASSERT_EQ(result->withdraw_url, "");
ASSERT_EQ(result->verify_url,
"https://sandbox.uphold.com/authorize/4c2b665ca060d912fec5c735c734859a0"
"6118cc8?scope=cards:read cards:write user:read transactions:read "
"6118cc8?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");
Expand Down Expand Up @@ -283,9 +293,11 @@ TEST(UpholdUtilTest, GenerateVerifyLink) {
auto result = braveledger_uphold::GenerateVerifyLink(wallet->Clone());
ASSERT_EQ(result,
"https://sandbox.uphold.com/authorize/4c2b665ca060d912fec5c735c734859a06"
"118cc8?scope=cards:read cards:write user:read transactions:read "
"transactions:transfer:application transactions:transfer:others&"
"intention=kyc&state=123123123124234234234");
"118cc8?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 = ledger::WalletStatus::CONNECTED;
Expand All @@ -304,18 +316,22 @@ TEST(UpholdUtilTest, GenerateVerifyLink) {
result = braveledger_uphold::GenerateVerifyLink(wallet->Clone());
ASSERT_EQ(result,
"https://sandbox.uphold.com/authorize/4c2b665ca060d912fec5c735c734859a06"
"118cc8?scope=cards:read cards:write user:read transactions:read "
"transactions:transfer:application transactions:transfer:others&"
"intention=kyc&state=123123123124234234234");
"118cc8?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 = ledger::WalletStatus::DISCONNECTED_VERIFIED;
result = braveledger_uphold::GenerateVerifyLink(wallet->Clone());
ASSERT_EQ(result,
"https://sandbox.uphold.com/authorize/4c2b665ca060d912fec5c735c734859a06"
"118cc8?scope=cards:read cards:write user:read transactions:read "
"transactions:transfer:application transactions:transfer:others&"
"intention=kyc&state=123123123124234234234");
"118cc8?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 = ledger::WalletStatus::PENDING;
Expand Down

0 comments on commit 970d3c4

Please sign in to comment.