Skip to content
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

Accept a response code of 206 from Uphold cards endpoint (uplift to 1.62.x) #21885

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mojom::Result GetCards::CheckStatusCode(int status_code) const {
return mojom::Result::EXPIRED_TOKEN;
}

if (status_code != net::HTTP_OK) {
if (status_code != net::HTTP_OK && status_code != net::HTTP_PARTIAL_CONTENT) {
BLOG(0, "Unexpected HTTP status: " << status_code);
return mojom::Result::FAILED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

// GET https://api.uphold.com/v0/me/cards?q=currency:BAT
//
// Success code:
// Success codes:
// HTTP_OK (200)
// HTTP_PARTIAL_CONTENT (206)
//
// Error codes:
// HTTP_UNAUTHORIZED (401)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,35 @@ TEST_F(GetCardsTest, ServerOK) {
task_environment_.RunUntilIdle();
}

TEST_F(GetCardsTest, ServerPartialContent) {
EXPECT_CALL(*mock_engine_impl_.mock_client(), LoadURL(_, _))
.Times(1)
.WillOnce([](mojom::UrlRequestPtr request, auto callback) {
auto response = mojom::UrlResponse::New();
response->status_code = 206;
response->url = request->url;
response->body = R"([
{
"available": "12.35",
"balance": "12.35",
"currency": "BAT",
"id": "3ed3b2c4-a715-4c01-b302-fa2681a971ea",
"label": "Brave Browser"
}
])";
std::move(callback).Run(std::move(response));
});

base::MockCallback<GetCardsCallback> callback;
EXPECT_CALL(callback,
Run(mojom::Result::OK,
std::string("3ed3b2c4-a715-4c01-b302-fa2681a971ea")))
.Times(1);
card_.Request("4c2b665ca060d912fec5c735c734859a06118cc8", callback.Get());

task_environment_.RunUntilIdle();
}

TEST_F(GetCardsTest, CardNotFound) {
EXPECT_CALL(*mock_engine_impl_.mock_client(), LoadURL(_, _))
.Times(1)
Expand Down
Loading