diff --git a/pom.xml b/pom.xml
index a45fe39..c8e997c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,6 +34,7 @@
${jenkins.baseline}.3
jenkinsci/${project.artifactId}-plugin
false
+ false
true
diff --git a/src/test/java/com/nowsecure/models/NowSecureBinaryTest.java b/src/test/java/com/nowsecure/models/NowSecureBinaryTest.java
index c3dbb89..2929808 100644
--- a/src/test/java/com/nowsecure/models/NowSecureBinaryTest.java
+++ b/src/test/java/com/nowsecure/models/NowSecureBinaryTest.java
@@ -1,34 +1,34 @@
package com.nowsecure.models;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.*;
import hudson.FilePath;
import java.io.File;
import java.nio.file.Paths;
import java.util.List;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
@WithJenkins
-class NowSecureBinaryTests {
- final String arch = System.getProperty("os.arch");
- final String osName = System.getProperty("os.name");
+class NowSecureBinaryTest {
+
+ private static final String ARCH = System.getProperty("os.arch");
+ private static final String OS_NAME = System.getProperty("os.name");
@CsvSource({"x8664", "amd64", "ia32e", "em64t", "x64"})
@ParameterizedTest
void shouldReturnAmd64ForAll64BitArchitectures_linux(String arch) throws Exception {
var actual = NowSecureBinary.getToolName(arch, "linux");
- Assertions.assertEquals("ns_linux-amd64", actual, "Not matching");
+ assertEquals("ns_linux-amd64", actual, "Not matching");
}
@CsvSource({"x8664", "amd64", "ia32e", "em64t", "x64"})
@ParameterizedTest
void shouldReturnAmd64ForAll64BitArchitectures_windows(String arch) throws Exception {
var actual = NowSecureBinary.getToolName(arch, "windows");
- Assertions.assertEquals("ns_windows-amd64.exe", actual, "Not matching");
+ assertEquals("ns_windows-amd64.exe", actual, "Not matching");
}
@CsvSource({
@@ -38,40 +38,39 @@ void shouldReturnAmd64ForAll64BitArchitectures_windows(String arch) throws Excep
"arm64,windows",
})
@ParameterizedTest
- void shouldFailWhenGivenInvalidArchitecutrePlatformCombo(String arch, String platform) throws Exception {
+ void shouldFailWhenGivenInvalidArchitecturePlatformCombo(String arch, String platform) throws Exception {
Exception exception = assertThrows(IllegalArgumentException.class, () -> {
NowSecureBinary.getToolName(arch, platform);
});
- Assertions.assertTrue(exception.getMessage().contains("Unsupported platform / architecture"));
+ assertTrue(exception.getMessage().contains("Unsupported platform / architecture"));
}
@Test
- void shouldTrackTokenIndeces() throws Exception {
+ void shouldTrackTokenIndices() throws Exception {
var resourceDir = this.getClass().getClassLoader().getResource("./");
- var nsb = new NowSecureBinary(arch, osName, new FilePath(new File(resourceDir.getPath())));
- Assertions.assertEquals(List.of(), nsb.maskedIndices, "Initial masked indeces list should be empty");
+ var nsb = new NowSecureBinary(ARCH, OS_NAME, new FilePath(new File(resourceDir.getPath())));
+ assertEquals(List.of(), nsb.maskedIndices, "Initial masked indices list should be empty");
nsb.addArgument("some-argument").addToken("some-token").addArgument("double", "argument");
- Assertions.assertEquals(List.of(3), nsb.maskedIndices);
+ assertEquals(List.of(3), nsb.maskedIndices);
nsb.addToken("new-token");
- Assertions.assertEquals(List.of(3, 7), nsb.maskedIndices);
- Assertions.assertEquals(nsb.arguments.size(), 8);
+ assertEquals(List.of(3, 7), nsb.maskedIndices);
+ assertEquals(8, nsb.arguments.size());
}
@Test
void shouldAddToolPathToProcessArgumentList() throws Exception {
var resourceDir = this.getClass().getClassLoader().getResource("./");
- var nsb = new NowSecureBinary(arch, osName, new FilePath(new File(resourceDir.getPath())));
- var toolName = NowSecureBinary.getToolName(arch, osName);
+ var nsb = new NowSecureBinary(ARCH, OS_NAME, new FilePath(new File(resourceDir.getPath())));
+ var toolName = NowSecureBinary.getToolName(ARCH, OS_NAME);
var constructedToolPath = nsb.toolPath.getRemote();
- Assertions.assertEquals(
- String.format("%s%s%s", Paths.get(resourceDir.toURI()).toString(), File.separator, toolName),
+ assertEquals(
+ String.format("%s%s%s", Paths.get(resourceDir.toURI()), File.separator, toolName),
constructedToolPath,
"Tool path does not look like it should");
- Assertions.assertEquals(
- List.of(constructedToolPath), nsb.arguments, "Tool path not properly added to arguments list");
+ assertEquals(List.of(constructedToolPath), nsb.arguments, "Tool path not properly added to arguments list");
}
}
diff --git a/src/test/java/com/nowsecure/plugin/NowSecurePluginTest.java b/src/test/java/com/nowsecure/plugin/NowSecurePluginTest.java
index 51902e7..010f0af 100644
--- a/src/test/java/com/nowsecure/plugin/NowSecurePluginTest.java
+++ b/src/test/java/com/nowsecure/plugin/NowSecurePluginTest.java
@@ -1,6 +1,7 @@
package com.nowsecure.plugin;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.CredentialsScope;
@@ -14,7 +15,6 @@
import hudson.util.Secret;
import java.io.IOException;
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
@@ -24,10 +24,10 @@
@WithJenkins
class NowSecurePluginTest {
- final String binaryFilePath = "./";
- final String group = "group";
+ private static final String BINARY_FILE_PATH = "./";
+ private static final String GROUP = "group";
- public void setupCredentials(JenkinsRule jenkins, String secretId, String secretText) throws IOException {
+ private void setupCredentials(JenkinsRule jenkins, String secretId, String secretText) throws IOException {
var secret = Secret.fromString(secretText);
StringCredentialsImpl credential =
new StringCredentialsImpl(CredentialsScope.GLOBAL, secretId, "Test plain text credential", secret);
@@ -39,7 +39,7 @@ public void setupCredentials(JenkinsRule jenkins, String secretId, String secret
@Test
void invalidCredentialIdShouldFail(JenkinsRule jenkins) throws Exception {
FreeStyleProject project = jenkins.createFreeStyleProject();
- var builder = new NowSecurePlugin(binaryFilePath, group, "bad token credential id");
+ var builder = new NowSecurePlugin(BINARY_FILE_PATH, GROUP, "bad token credential id");
project.getBuildersList().add(builder);
var build = jenkins.buildAndAssertStatus(Result.FAILURE, project);
jenkins.assertLogContains("Could not find a TextCredential matching the specified credentialId", build);
@@ -51,7 +51,7 @@ void validCredentialIdShouldSucceed_unix(JenkinsRule jenkins) throws Exception {
FreeStyleProject project = jenkins.createFreeStyleProject();
var id = "some-id";
setupCredentials(jenkins, id, "some-text");
- var builder = new NowSecurePlugin(binaryFilePath, group, id);
+ var builder = new NowSecurePlugin(BINARY_FILE_PATH, GROUP, id);
project.getBuildersList().add(builder);
var build = jenkins.buildAndAssertStatus(Result.SUCCESS, project);
jenkins.assertLogNotContains("Could not find a TextCredential matching the specified credentialId", build);
@@ -65,7 +65,7 @@ void validCredentialIdShouldSucceed_windows(JenkinsRule jenkins) throws Exceptio
FreeStyleProject project = jenkins.createFreeStyleProject();
var id = "some-id";
setupCredentials(jenkins, id, "some-text");
- var builder = new NowSecurePlugin(binaryFilePath, group, id);
+ var builder = new NowSecurePlugin(BINARY_FILE_PATH, GROUP, id);
project.getBuildersList().add(builder);
var build = jenkins.buildAndAssertStatus(Result.FAILURE, project);
jenkins.assertLogNotContains("Could not find a TextCredential matching the specified credentialId", build);
@@ -75,7 +75,7 @@ void validCredentialIdShouldSucceed_windows(JenkinsRule jenkins) throws Exceptio
void shouldAllowUsersToOverrideURLs(JenkinsRule jenkins) throws Exception {
var id = "some-id";
setupCredentials(jenkins, id, "some-text");
- var nsStep = new NowSecurePlugin(binaryFilePath, group, id);
+ var nsStep = new NowSecurePlugin(BINARY_FILE_PATH, GROUP, id);
var apiUrl = "https://httpbin.org/api";
var uiUrl = "https://httpbin.org/ui";
@@ -83,8 +83,8 @@ void shouldAllowUsersToOverrideURLs(JenkinsRule jenkins) throws Exception {
nsStep.setApiHost(apiUrl);
nsStep.setUiHost(uiUrl);
- Assertions.assertEquals(apiUrl, nsStep.getApiHost());
- Assertions.assertEquals(uiUrl, nsStep.getUiHost());
+ assertEquals(apiUrl, nsStep.getApiHost());
+ assertEquals(uiUrl, nsStep.getUiHost());
}
@Test
@@ -92,7 +92,7 @@ void shouldPersistUserConfigs(JenkinsRule jenkins) throws Exception {
FreeStyleProject project = jenkins.createFreeStyleProject();
var id = "some-id";
setupCredentials(jenkins, id, "some-text");
- var nsStep = new NowSecurePlugin(binaryFilePath, group, id);
+ var nsStep = new NowSecurePlugin(BINARY_FILE_PATH, GROUP, id);
var apiUrl = "https://httpbin.org/api";
var uiUrl = "https://httpbin.org/ui";
@@ -117,8 +117,8 @@ void shouldPersistUserConfigs(JenkinsRule jenkins) throws Exception {
assertNotNull(reloadedStep);
// Data bound constructor fields
- assertEquals(binaryFilePath, reloadedStep.getBinaryFilePath());
- assertEquals(group, reloadedStep.getGroup());
+ assertEquals(BINARY_FILE_PATH, reloadedStep.getBinaryFilePath());
+ assertEquals(GROUP, reloadedStep.getGroup());
assertEquals(id, reloadedStep.getTokenCredentialId());
// Data bound setter fields
assertEquals(apiUrl, reloadedStep.getApiHost());