Skip to content

Commit

Permalink
Merge pull request #3547 from brave/pending-wallet-url
Browse files Browse the repository at this point in the history
Adds verify url for pending wallet
  • Loading branch information
NejcZdovc authored Oct 1, 2019
2 parents 6a7619d + fdd54e6 commit 72357f3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void UpholdAuthorization::OnGetUser(
}
} else {
wallet_ptr->status = ledger::WalletStatus::PENDING;
args["redirect_url"] = GetSecondStepRegistration();
args["redirect_url"] = GetSecondStepVerify();
}

ledger_->SaveExternalWallet(ledger::kWalletUphold, std::move(wallet_ptr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@ std::string GetSecondStepVerify() {
id.c_str());
}

std::string GetSecondStepRegistration() {
const std::string url = GetUrl();

return base::StringPrintf(
"%s/signup/step2",
url.c_str());
}

ledger::ExternalWalletPtr GetWallet(
std::map<std::string, ledger::ExternalWalletPtr> wallets) {
for (auto& wallet : wallets) {
Expand Down Expand Up @@ -188,8 +180,8 @@ ledger::ExternalWalletPtr GenerateLinks(ledger::ExternalWalletPtr wallet) {

switch (wallet->status) {
case ledger::WalletStatus::PENDING: {
wallet->add_url = GetSecondStepRegistration();
wallet->withdraw_url = GetSecondStepRegistration();
wallet->add_url = GetSecondStepVerify();
wallet->withdraw_url = GetSecondStepVerify();
break;
}
case ledger::WalletStatus::CONNECTED: {
Expand Down Expand Up @@ -225,7 +217,7 @@ std::string GenerateVerifyLink(ledger::ExternalWalletPtr wallet) {

switch (wallet->status) {
case ledger::WalletStatus::PENDING: {
url = GetSecondStepRegistration();
url = GetSecondStepVerify();
break;
}
case ledger::WalletStatus::CONNECTED: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ std::string GetWithdrawUrl(const std::string& address);

std::string GetSecondStepVerify();

std::string GetSecondStepRegistration();

ledger::ExternalWalletPtr GetWallet(
std::map<std::string, ledger::ExternalWalletPtr> wallets);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,6 @@ TEST(UpholdUtilTest, GetSecondStepVerify) {
"application_id=4c2b665ca060d912fec5c735c734859a06118cc8&intention=kyc");
}

TEST(UpholdUtilTest, GetSecondStepRegistration) {
// production
ledger::is_production = true;
std::string result = braveledger_uphold::GetSecondStepRegistration();
ASSERT_EQ(result,
"https://uphold.com/signup/step2");

// staging
ledger::is_production = false;
result = braveledger_uphold::GetSecondStepRegistration();
ASSERT_EQ(result,
"https://sandbox.uphold.com/signup/step2");
}

TEST(UpholdUtilTest, GetWallet) {
// no wallets
std::map<std::string, ledger::ExternalWalletPtr> wallets;
Expand Down Expand Up @@ -292,9 +278,18 @@ TEST(UpholdUtilTest, GenerateLinks) {
// Pending
wallet->status = ledger::WalletStatus::PENDING;
result = braveledger_uphold::GenerateLinks(wallet->Clone());
ASSERT_EQ(result->add_url, "https://sandbox.uphold.com/signup/step2");
ASSERT_EQ(result->withdraw_url, "https://sandbox.uphold.com/signup/step2");
ASSERT_EQ(result->verify_url, "https://sandbox.uphold.com/signup/step2");
ASSERT_EQ(result->add_url,
"https://sandbox.uphold.com/signup/step2?"
"application_id=4c2b665ca060d912fec5c735c734859a06118cc8&"
"intention=kyc");
ASSERT_EQ(result->withdraw_url,
"https://sandbox.uphold.com/signup/step2?"
"application_id=4c2b665ca060d912fec5c735c734859a06118cc8&"
"intention=kyc");
ASSERT_EQ(result->verify_url,
"https://sandbox.uphold.com/signup/step2?"
"application_id=4c2b665ca060d912fec5c735c734859a06118cc8&"
"intention=kyc");
ASSERT_EQ(result->account_url, "https://sandbox.uphold.com/dashboard");
}

Expand Down Expand Up @@ -346,7 +341,10 @@ TEST(UpholdUtilTest, GenerateVerifyLink) {
// Pending
wallet->status = ledger::WalletStatus::PENDING;
result = braveledger_uphold::GenerateVerifyLink(wallet->Clone());
ASSERT_EQ(result, "https://sandbox.uphold.com/signup/step2");
ASSERT_EQ(result,
"https://sandbox.uphold.com/signup/step2?"
"application_id=4c2b665ca060d912fec5c735c734859a06118cc8&"
"intention=kyc");
}

} // namespace braveledger_uphold

0 comments on commit 72357f3

Please sign in to comment.