forked from redhat-developer/intellij-openshift-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: parse login command regexp and other regexp (redhat-developer#884)
* fix: parse login command regexp and other regexp Signed-off-by: Stephane Bouchet <[email protected]> * fix: parse login command regexp and other regexp Signed-off-by: Stephane Bouchet <[email protected]> * fix: parse login command regexp and other regexp Signed-off-by: Stephane Bouchet <[email protected]> --------- Signed-off-by: Stephane Bouchet <[email protected]>
- Loading branch information
Showing
10 changed files
with
525 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/test/java/org/jboss/tools/intellij/openshift/ui/cluster/TokenExtractorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.intellij.openshift.ui.cluster; | ||
|
||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
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>"; | ||
TokenExtractor extractor = new TokenExtractor(contents); | ||
assertTrue(extractor.isTokenPage()); | ||
assertEquals("sha256~abcd-1234567890ABCDEF", extractor.getToken()); | ||
} | ||
|
||
@Test | ||
public void checkTokenExtractionEmpty() { | ||
String contents = "<html><head></head><body><h2>Your API token is</h2>\n <code></code>\n</body></html>"; | ||
TokenExtractor extractor = new TokenExtractor(contents); | ||
assertTrue(extractor.isTokenPage()); | ||
assertEquals("", extractor.getToken()); | ||
} | ||
|
||
@Test | ||
public void checkTokenExtractionFails() { | ||
String contents = "<html><head></head><body></body></html>"; | ||
TokenExtractor extractor = new TokenExtractor(contents); | ||
assertFalse(extractor.isTokenPage()); | ||
} | ||
|
||
@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>"; | ||
TokenExtractor extractor = new TokenExtractor(contents); | ||
assertTrue(extractor.isTokenPage()); | ||
assertEquals("sha256~abcd-1234567890ABCDEF", extractor.getToken()); | ||
} | ||
} |
Oops, something went wrong.