From b5967cf29702c6669a01a68663455ef211444c89 Mon Sep 17 00:00:00 2001 From: Stephane Bouchet Date: Mon, 29 Jul 2024 11:57:08 +0200 Subject: [PATCH] chore: add false positive leak comment on tokens tests (#885) Signed-off-by: Stephane Bouchet --- .../ui/cluster/TokenExtractorTest.java | 4 +- .../openshift/utils/OCCommandUtilsTest.java | 38 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/test/java/org/jboss/tools/intellij/openshift/ui/cluster/TokenExtractorTest.java b/src/test/java/org/jboss/tools/intellij/openshift/ui/cluster/TokenExtractorTest.java index 15f488fa5..44e7502bb 100644 --- a/src/test/java/org/jboss/tools/intellij/openshift/ui/cluster/TokenExtractorTest.java +++ b/src/test/java/org/jboss/tools/intellij/openshift/ui/cluster/TokenExtractorTest.java @@ -21,7 +21,7 @@ public class TokenExtractorTest { @Test public void checkTokenExtractionOk() { - String contents = "

Your API token is

\n sha256~abcd-1234567890ABCDEF\n"; + String contents = "

Your API token is

\n sha256~abcd-1234567890ABCDEF\n"; //# notsecret TokenExtractor extractor = new TokenExtractor(contents); assertTrue(extractor.isTokenPage()); assertEquals("sha256~abcd-1234567890ABCDEF", extractor.getToken()); @@ -44,7 +44,7 @@ public void checkTokenExtractionFails() { @Test public void checkTokenExtractionWithMultipleH2() { - String contents = "

Your API token is

\n sha256~abcd-1234567890ABCDEF\n

Log in with this token

\n
oc login --token=sha256~abcd-1234567890ABCDEF --server=https://url.com:1234
"; + String contents = "

Your API token is

\n sha256~abcd-1234567890ABCDEF\n

Log in with this token

\n
oc login --token=sha256~abcd-1234567890ABCDEF --server=https://url.com:1234
"; //# notsecret TokenExtractor extractor = new TokenExtractor(contents); assertTrue(extractor.isTokenPage()); assertEquals("sha256~abcd-1234567890ABCDEF", extractor.getToken()); diff --git a/src/test/java/org/jboss/tools/intellij/openshift/utils/OCCommandUtilsTest.java b/src/test/java/org/jboss/tools/intellij/openshift/utils/OCCommandUtilsTest.java index 2c195b568..598f418d5 100644 --- a/src/test/java/org/jboss/tools/intellij/openshift/utils/OCCommandUtilsTest.java +++ b/src/test/java/org/jboss/tools/intellij/openshift/utils/OCCommandUtilsTest.java @@ -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 @@ -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