Skip to content

Commit 8e52082

Browse files
Update TestMultiValidationTokeFile token generation with no trailing newline char
Description The test does the following: 1.Randomly appends new-line character to the token value buffer 2. If #1 is done, it generates temp token file with buffer containing new-line character. 3. Also, it remember the original token for future validation 4. The code parse and read token-validation files and removes the new-line character as desired. Failure in this case due to random buffer used to populate token value contained newline character which was used for validation, however, the file parse/read code as expected removed the newline character, hence causing the mismatch. Patch addresses the concern by ensuring test generated random token-value has no trailing newline chars. Testing tests/fast/RandomUnitTests.toml -s 1355028229
1 parent 982ccff commit 8e52082

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fdbserver/RESTKmsConnector.actor.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,17 @@ ACTOR Future<Void> testMultiValidationFileTokenFiles(Reference<RESTKmsConnectorC
12641264
state std::string tokenDetailsStr;
12651265
state bool newLineAppended = BUGGIFY ? true : false;
12661266

1267-
deterministicRandom()->randomBytes(mutateString(buff), tokenLen);
1268-
std::string token((char*)buff.begin(), tokenLen);
1267+
std::string token;
1268+
// Construct token-value buffer ensuring it doesn't have trailing new-line character.
1269+
loop {
1270+
deterministicRandom()->randomBytes(mutateString(buff), tokenLen);
1271+
token = std::string((char*)buff.begin(), tokenLen);
1272+
removeTrailingChar(token, '\n');
1273+
if (token.size() > 0) {
1274+
break;
1275+
}
1276+
}
1277+
tokenLen = token.size();
12691278
std::string tokenWithNewLine(token);
12701279
tokenWithNewLine.push_back('\n');
12711280

0 commit comments

Comments
 (0)