generated from Huluvu424242/rades-example.template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#25] Refactoring: Umbenennung zu AbfrageDaten
- Loading branch information
Thomas Schubert
committed
Oct 13, 2019
1 parent
272efcc
commit c126047
Showing
7 changed files
with
158 additions
and
115 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
105 changes: 105 additions & 0 deletions
105
src/test/java/com/github/funthomas424242/jenkinsmonitor/jenkins/AbfrageDatenTest.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,105 @@ | ||
package com.github.funthomas424242.jenkinsmonitor.jenkins; | ||
|
||
/*- | ||
* #%L | ||
* Jenkins Monitor | ||
* %% | ||
* Copyright (C) 2019 PIUG | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
* #L% | ||
*/ | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.net.URL; | ||
import java.util.Base64; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class AbfrageDatenTest { | ||
|
||
@Test | ||
@DisplayName("Prüfe das alle Daten als Properties enthalten sind") | ||
public void containsAllProperties() { | ||
final AbfrageDaten abfrageDaten = assertDoesNotThrow(() -> { | ||
return new AbfrageDaten( | ||
new URL("http://localhost:8080/"), | ||
"Nutzername", | ||
"Passwort" | ||
|
||
); | ||
}); | ||
assertNotNull(abfrageDaten.getStatusAbfrageUrl()); | ||
assertEquals("Nutzername", abfrageDaten.getUserName()); | ||
assertEquals("Passwort", abfrageDaten.getPassword()); | ||
assertNotNull(abfrageDaten.getBasicAuthToken(abfrageDaten.getPassword())); | ||
} | ||
|
||
@Test | ||
@Disabled | ||
@DisplayName("Das BasicAuth Token wird korrekt mit base64 kodiert") | ||
public void getBase64CodedToken() { | ||
|
||
final AbfrageDaten abfrageDaten = assertDoesNotThrow(() -> { | ||
return new AbfrageDaten( | ||
new URL("http://localhost:8080/"), | ||
"Nutzername", | ||
"Passwort" | ||
); | ||
}); | ||
try { | ||
final String expectedToken = Base64.getEncoder().encodeToString("Nutzername:Passwort".getBytes("utf-8")); | ||
assertNotNull(abfrageDaten.getBasicAuthToken(abfrageDaten.getPassword())); | ||
} catch (UnsupportedEncodingException e) { | ||
fail(); | ||
} | ||
} | ||
|
||
@Test | ||
@DisplayName("Das BasicAuth Token wird bei gültigem Passwort zurückgegeben") | ||
public void getTokenWithValidPassword() { | ||
|
||
final AbfrageDaten abfrageDaten = assertDoesNotThrow(() -> { | ||
return new AbfrageDaten( | ||
new URL("http://localhost:8080/"), | ||
"Nutzername", | ||
"Passwort" | ||
); | ||
}); | ||
assertNotNull(abfrageDaten.getStatusAbfrageUrl()); | ||
assertEquals("Nutzername", abfrageDaten.getUserName()); | ||
assertEquals("Passwort", abfrageDaten.getPassword()); | ||
assertNotNull(abfrageDaten.getBasicAuthToken(abfrageDaten.getPassword())); | ||
} | ||
|
||
@Test | ||
@DisplayName("Als BasicAuth Token wird null bei ungültigem Passwort zurückgegeben") | ||
public void getNullWithInValidPassword() { | ||
|
||
final AbfrageDaten abfrageDaten = assertDoesNotThrow(() -> { | ||
return new AbfrageDaten( | ||
new URL("http://localhost:8080/"), | ||
"Nutzername", | ||
"Passwort" | ||
); | ||
}); | ||
assertNull(abfrageDaten.getBasicAuthToken("blah blup falsch")); | ||
} | ||
|
||
} |
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
Oops, something went wrong.