Skip to content

Commit 6235ccb

Browse files
committed
test: add unit test to confirm absence of pageToken param in listBuckets request, which causes the 1000+ buckets infinite pagination loop
1 parent 405eff5 commit 6235ccb

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

google/cloud/storage/internal/rest/stub_test.cc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ using ::testing::ElementsAre;
4040
using ::testing::Eq;
4141
using ::testing::HasSubstr;
4242
using ::testing::Matcher;
43+
using ::testing::Not;
4344
using ::testing::Pair;
4445
using ::testing::ResultOf;
4546
using ::testing::Return;
@@ -216,17 +217,12 @@ TEST(RestStubTest, ListBucketsOmitsPageTokenWhenEmptyInRequest) {
216217
auto mock = std::make_shared<MockRestClient>();
217218
ListBucketsRequest request("test-project-id");
218219

219-
EXPECT_CALL(*mock, Get(ExpectedContext(),
220-
ResultOf(
221-
"request parameters do not contain 'pageToken'",
222-
[](RestRequest const& r) {
223-
return std::none_of(
224-
r.parameters().begin(), r.parameters().end(),
225-
[](auto const& param) {
226-
return param.first == "pageToken";
227-
});
228-
},
229-
::testing::IsTrue())))
220+
EXPECT_CALL(*mock,
221+
Get(ExpectedContext(),
222+
ResultOf(
223+
"request parameters do not contain 'pageToken'",
224+
[](RestRequest const& r) { return r.parameters(); },
225+
Not(Contains(Pair("pageToken", _))))))
230226
.WillOnce(Return(PermanentError()));
231227

232228
auto tested = std::make_unique<RestStub>(Options{}, mock, mock);

0 commit comments

Comments
 (0)