Skip to content

Commit

Permalink
Update TestMultiValidationTokeFile token generation with no trailing …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
sfc-gh-ahusain committed Apr 11, 2023
1 parent 982ccff commit 8e52082
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions fdbserver/RESTKmsConnector.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,17 @@ ACTOR Future<Void> testMultiValidationFileTokenFiles(Reference<RESTKmsConnectorC
state std::string tokenDetailsStr;
state bool newLineAppended = BUGGIFY ? true : false;

deterministicRandom()->randomBytes(mutateString(buff), tokenLen);
std::string token((char*)buff.begin(), tokenLen);
std::string token;
// Construct token-value buffer ensuring it doesn't have trailing new-line character.
loop {
deterministicRandom()->randomBytes(mutateString(buff), tokenLen);
token = std::string((char*)buff.begin(), tokenLen);
removeTrailingChar(token, '\n');
if (token.size() > 0) {
break;
}
}
tokenLen = token.size();
std::string tokenWithNewLine(token);
tokenWithNewLine.push_back('\n');

Expand Down

0 comments on commit 8e52082

Please sign in to comment.