Skip to content

Commit

Permalink
chore: add false positive leak comment on tokens tests (redhat-develo…
Browse files Browse the repository at this point in the history
…per#885)

Signed-off-by: Stephane Bouchet <[email protected]>
  • Loading branch information
sbouchet authored Jul 29, 2024
1 parent d92992d commit b5967cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class TokenExtractorTest {

@Test
public void checkTokenExtractionOk() {
String contents = "<html><head></head><body><h2>Your API token is</h2>\n <code>sha256~abcd-1234567890ABCDEF</code>\n</body></html>";
String contents = "<html><head></head><body><h2>Your API token is</h2>\n <code>sha256~abcd-1234567890ABCDEF</code>\n</body></html>"; //# notsecret
TokenExtractor extractor = new TokenExtractor(contents);
assertTrue(extractor.isTokenPage());
assertEquals("sha256~abcd-1234567890ABCDEF", extractor.getToken());
Expand All @@ -44,7 +44,7 @@ public void checkTokenExtractionFails() {

@Test
public void checkTokenExtractionWithMultipleH2() {
String contents = "<html><head></head><body><h2>Your API token is</h2>\n <code>sha256~abcd-1234567890ABCDEF</code>\n<h2>Log in with this token</h2>\n<pre>oc login <span class=\"nowrap\">--token=sha256~abcd-1234567890ABCDEF</span> <span class=\"nowrap\">--server=https://url.com:1234</span></pre></body></html>";
String contents = "<html><head></head><body><h2>Your API token is</h2>\n <code>sha256~abcd-1234567890ABCDEF</code>\n<h2>Log in with this token</h2>\n<pre>oc login <span class=\"nowrap\">--token=sha256~abcd-1234567890ABCDEF</span> <span class=\"nowrap\">--server=https://url.com:1234</span></pre></body></html>"; //# notsecret
TokenExtractor extractor = new TokenExtractor(contents);
assertTrue(extractor.isTokenPage());
assertEquals("sha256~abcd-1234567890ABCDEF", extractor.getToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,33 @@ public class OCCommandUtilsTest {
@Test
public void testCommandWithToken() {
assertEquals("123456789123456789",
OCCommandUtils.getToken("oc login https://api.engint.openshift.com --token=123456789123456789"));
OCCommandUtils.getToken("oc login https://api.engint.openshift.com --token=123456789123456789")); //# notsecret
assertEquals("123456789123456789",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=123456789123456789 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=123456789123456789 ")); //# notsecret
assertEquals("1234567891234567..89",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=1234567891234567..89 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=1234567891234567..89 ")); //# notsecret
assertEquals("12345678912345678_9",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=12345678912345678_9 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=12345678912345678_9 ")); //# notsecret
assertEquals("1234567891234567.89",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=1234567891234567.89 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=1234567891234567.89 ")); //# notsecret
assertEquals("1234567891234567-89",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=1234567891234567-89 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=1234567891234567-89 ")); //# notsecret
}

@Test
public void testCommandWithTokenOCP4() {
assertEquals("sha256~123456789123456789",
OCCommandUtils.getToken("oc login https://api.engint.openshift.com --token=sha256~123456789123456789"));
OCCommandUtils.getToken("oc login https://api.engint.openshift.com --token=sha256~123456789123456789")); //# notsecret
assertEquals("sha256~123456789123456789",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~123456789123456789 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~123456789123456789 ")); //# notsecret
assertEquals("sha256~1234567891234567..89",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~1234567891234567..89 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~1234567891234567..89 ")); //# notsecret
assertEquals("sha256~12345678912345678_9",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~12345678912345678_9 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~12345678912345678_9 ")); //# notsecret
assertEquals("sha256~1234567891234567.89",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~1234567891234567.89 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~1234567891234567.89 ")); //# notsecret
assertEquals("sha256~1234567891234567-89",
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~1234567891234567-89 "));
OCCommandUtils.getToken("oc login https://api.-uengint.openshift.com --token=sha256~1234567891234567-89 ")); //# notsecret
}

@Test
Expand All @@ -68,24 +68,24 @@ public void testCommandWithPassword() {
@Test
public void testValidCommand() {
assertFalse(
OCCommandUtils.isValidCommand("oc loginhttps://api.engint.openshift.com --token=123456789123456789"));
OCCommandUtils.isValidCommand("oc loginhttps://api.engint.openshift.com --token=123456789123456789")); //# notsecret
assertTrue(
OCCommandUtils.isValidCommand("oc login https://api.engint.openshift.com --token=123456789123456789"));
OCCommandUtils.isValidCommand("oc login https://api.engint.openshift.com --token=123456789123456789")); //# notsecret
assertTrue(OCCommandUtils.isValidCommand("oc login https://12.34.5.6:8443 -u developer -p deve"));
}

@Test
public void testServerAddress() {
assertEquals("https://api.engint.openshift.com",
OCCommandUtils.getServer("oc login https://api.engint.openshift.com --token=123456789123456789"));
OCCommandUtils.getServer("oc login https://api.engint.openshift.com --token=123456789123456789")); //# notsecret
assertEquals("https://api.engint.openshift.com",
OCCommandUtils.getServer("oc login -s=https://api.engint.openshift.com --token=123456789123456789"));
OCCommandUtils.getServer("oc login -s=https://api.engint.openshift.com --token=123456789123456789")); //# notsecret
assertEquals("https://api.engint.openshift.com",
OCCommandUtils.getServer("oc login -s https://api.engint.openshift.com --token=123456789123456789"));
OCCommandUtils.getServer("oc login -s https://api.engint.openshift.com --token=123456789123456789")); //# notsecret
assertEquals("https://api.engint.openshift.com",
OCCommandUtils.getServer("oc login --server=https://api.engint.openshift.com --token=123456789123456789"));
OCCommandUtils.getServer("oc login --server=https://api.engint.openshift.com --token=123456789123456789")); //# notsecret
assertEquals("https://api.engint.openshift.com",
OCCommandUtils.getServer("oc login --server https://api.engint.openshift.com --token=123456789123456789"));
OCCommandUtils.getServer("oc login --server https://api.engint.openshift.com --token=123456789123456789")); //# notsecret
}

@Test
Expand Down

0 comments on commit b5967cf

Please sign in to comment.