소스 검색

test: fix dangling-temporary UB in keys-list assertion (bind parsed json to a named var)

Fszontagh 2 달 전
부모
커밋
5383002b86
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      tests/test_api_integration.cpp

+ 2 - 1
tests/test_api_integration.cpp

@@ -55,7 +55,8 @@ TEST_F(ApiFixture, KeysCrudAndScopedAuthz) {
     // list masks the secret
     auto list = c.Get("/api/v1/keys");
     ASSERT_EQ(list->status, 200);
-    for (auto& k : nlohmann::json::parse(list->body)["keys"]) EXPECT_FALSE(k.contains("key"));
+    auto keysJson = nlohmann::json::parse(list->body);
+    for (auto& k : keysJson["keys"]) EXPECT_FALSE(k.contains("key"));
 
     // scoped key can access its project, but not management or another project
     EXPECT_EQ(http(scopedKey).Get(("/api/v1/projects/" + project_).c_str())->status, 200);