Skip to content

Commit

Permalink
Uplift of #21647 (squashed) to release
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-builds committed Feb 2, 2024
1 parent a07b255 commit 6e732ce
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
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

0 comments on commit 6e732ce

Please sign in to comment.