diff --git a/src/test/java/com/onepassword/jenkins/plugins/OnePasswordWithSecretsTest.java b/src/test/java/com/onepassword/jenkins/plugins/OnePasswordWithSecretsTest.java index 489f798..c0722a8 100644 --- a/src/test/java/com/onepassword/jenkins/plugins/OnePasswordWithSecretsTest.java +++ b/src/test/java/com/onepassword/jenkins/plugins/OnePasswordWithSecretsTest.java @@ -9,20 +9,20 @@ import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.jenkinsci.plugins.workflow.job.WorkflowRun; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.jvnet.hudson.test.JenkinsRule; +import org.jvnet.hudson.test.junit.jupiter.WithJenkins; import java.io.IOException; import java.nio.charset.Charset; import static com.onepassword.jenkins.plugins.util.TestConstants.*; -public class OnePasswordWithSecretsTest { +@WithJenkins +class OnePasswordWithSecretsTest { - @Rule - public JenkinsRule j = new JenkinsRule(); + private JenkinsRule j; private final String basePath = "src/test/resources/com/onepassword/jenkins/plugins/pipeline/"; @@ -31,8 +31,9 @@ public class OnePasswordWithSecretsTest { CredentialsScope.GLOBAL, "connect-credential-id", "1Password Connect Credential", Secret.fromString(System.getenv("OP_TOKEN"))); - @Before - public void init() throws IOException { + @BeforeEach + void init(JenkinsRule j) throws IOException { + this.j = j; CredentialsProvider.lookupStores(j.jenkins) .iterator() .next() @@ -40,7 +41,7 @@ public void init() throws IOException { } @Test - public void testSecretsFunction() throws Exception { + void testSecretsFunction() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testSecretsFunction.groovy", Charset.defaultCharset()) @@ -53,7 +54,7 @@ public void testSecretsFunction() throws Exception { } @Test - public void testSecretsPipeline() throws Exception { + void testSecretsPipeline() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testSecretsPipeline.groovy", Charset.defaultCharset()) @@ -67,7 +68,7 @@ public void testSecretsPipeline() throws Exception { } @Test - public void testSecretsMultiline() throws Exception { + void testSecretsMultiline() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testSecretsMultiline.groovy", Charset.defaultCharset()) @@ -81,7 +82,7 @@ public void testSecretsMultiline() throws Exception { } @Test - public void testSecretsFromEnv() throws Exception { + void testSecretsFromEnv() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testSecretsFromEnv.groovy", Charset.defaultCharset()) @@ -95,7 +96,7 @@ public void testSecretsFromEnv() throws Exception { } @Test - public void testSecretsWrongReference() throws Exception { + void testSecretsWrongReference() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testSecretsWrongReference.groovy", Charset.defaultCharset()) @@ -109,7 +110,7 @@ public void testSecretsWrongReference() throws Exception { } @Test - public void testSecretsMasked() throws Exception { + void testSecretsMasked() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testSecretsMasked.groovy", Charset.defaultCharset()) @@ -122,7 +123,7 @@ public void testSecretsMasked() throws Exception { } @Test - public void testSecretsMultilineMasked() throws Exception { + void testSecretsMultilineMasked() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testSecretsMultilineMasked.groovy", Charset.defaultCharset()) diff --git a/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordConfigConnectTest.java b/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordConfigConnectTest.java index ed0e579..2bed551 100644 --- a/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordConfigConnectTest.java +++ b/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordConfigConnectTest.java @@ -10,20 +10,20 @@ import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.jenkinsci.plugins.workflow.job.WorkflowRun; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.jvnet.hudson.test.JenkinsRule; +import org.jvnet.hudson.test.junit.jupiter.WithJenkins; import java.io.IOException; import java.nio.charset.Charset; import static com.onepassword.jenkins.plugins.util.TestConstants.*; -public class OnePasswordConfigConnectTest { +@WithJenkins +class OnePasswordConfigConnectTest { - @Rule - public JenkinsRule j = new JenkinsRule(); + private JenkinsRule j; private final String basePath = "src/test/resources/com/onepassword/jenkins/plugins/config/connect/"; @@ -32,8 +32,9 @@ public class OnePasswordConfigConnectTest { CredentialsScope.GLOBAL, "connect-credential-id", "1Password Connect Credential", Secret.fromString(System.getenv("OP_TOKEN"))); - @Before - public void init() throws IOException { + @BeforeEach + void init(JenkinsRule j) throws IOException { + this.j = j; CredentialsProvider.lookupStores(j.jenkins) .iterator() .next() @@ -41,7 +42,7 @@ public void init() throws IOException { } @Test - public void testConfigFunction() throws Exception { + void testConfigFunction() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigFunction.groovy", Charset.defaultCharset()) @@ -55,7 +56,7 @@ public void testConfigFunction() throws Exception { } @Test - public void testConfigPipeline() throws Exception { + void testConfigPipeline() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigPipeline.groovy", Charset.defaultCharset()) @@ -69,7 +70,7 @@ public void testConfigPipeline() throws Exception { } @Test - public void testConfigGlobal() throws Exception { + void testConfigGlobal() throws Exception { OnePasswordGlobalConfig globalConfig = GlobalConfiguration.all().get(OnePasswordGlobalConfig.class); OnePasswordConfig config = new OnePasswordConfig(); config.setConnectHost(TEST_CONNECT_HOST); @@ -93,7 +94,7 @@ public void testConfigGlobal() throws Exception { } @Test - public void testConfigMergeHost() throws Exception { + void testConfigMergeHost() throws Exception { OnePasswordGlobalConfig globalConfig = GlobalConfiguration.all().get(OnePasswordGlobalConfig.class); OnePasswordConfig config = new OnePasswordConfig(); config.setConnectHost(TEST_CONNECT_HOST); @@ -115,7 +116,7 @@ public void testConfigMergeHost() throws Exception { } @Test - public void testConfigMergeTokenId() throws Exception { + void testConfigMergeTokenId() throws Exception { OnePasswordGlobalConfig globalConfig = GlobalConfiguration.all().get(OnePasswordGlobalConfig.class); OnePasswordConfig config = new OnePasswordConfig(); config.setConnectCredentialId("connect-credential-id"); @@ -138,7 +139,7 @@ public void testConfigMergeTokenId() throws Exception { } @Test - public void testConfigFromEnv() throws Exception { + void testConfigFromEnv() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigFromEnv.groovy", Charset.defaultCharset()) @@ -152,7 +153,7 @@ public void testConfigFromEnv() throws Exception { } @Test - public void testConfigPriorityHost() throws Exception { + void testConfigPriorityHost() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigPriorityHost.groovy", Charset.defaultCharset()) @@ -166,7 +167,7 @@ public void testConfigPriorityHost() throws Exception { } @Test - public void testConfigPriorityToken() throws Exception { + void testConfigPriorityToken() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigPriorityToken.groovy", Charset.defaultCharset()) @@ -180,7 +181,7 @@ public void testConfigPriorityToken() throws Exception { } @Test - public void testConfigNoHost() throws Exception { + void testConfigNoHost() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigNoHost.groovy", Charset.defaultCharset()) @@ -194,7 +195,7 @@ public void testConfigNoHost() throws Exception { } @Test - public void testConfigNoToken() throws Exception { + void testConfigNoToken() throws Exception { CredentialsProvider.lookupStores(j.jenkins) .iterator() .next() @@ -212,7 +213,7 @@ public void testConfigNoToken() throws Exception { } @Test - public void testConfigNoConfig() throws Exception { + void testConfigNoConfig() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigNoConfig.groovy", Charset.defaultCharset()) @@ -226,7 +227,7 @@ public void testConfigNoConfig() throws Exception { } @Test - public void testConfigNoSpecifiedToken() throws Exception { + void testConfigNoSpecifiedToken() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigNoSpecifiedToken.groovy", Charset.defaultCharset()) @@ -240,7 +241,7 @@ public void testConfigNoSpecifiedToken() throws Exception { } @Test - public void testConfigWrongHost() throws Exception { + void testConfigWrongHost() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigWrongHost.groovy", Charset.defaultCharset()) diff --git a/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordConfigServiceAccountTest.java b/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordConfigServiceAccountTest.java index c004eb8..bcda2d3 100644 --- a/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordConfigServiceAccountTest.java +++ b/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordConfigServiceAccountTest.java @@ -10,20 +10,20 @@ import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.jenkinsci.plugins.workflow.job.WorkflowRun; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.jvnet.hudson.test.JenkinsRule; +import org.jvnet.hudson.test.junit.jupiter.WithJenkins; import java.io.IOException; import java.nio.charset.Charset; import static com.onepassword.jenkins.plugins.util.TestConstants.*; -public class OnePasswordConfigServiceAccountTest { +@WithJenkins +class OnePasswordConfigServiceAccountTest { - @Rule - public JenkinsRule j = new JenkinsRule(); + private JenkinsRule j; private final String basePath = "src/test/resources/com/onepassword/jenkins/plugins/config/serviceaccount/"; private final String serviceAccountCredentialId = "service-account-credential-id"; @@ -33,8 +33,9 @@ public class OnePasswordConfigServiceAccountTest { CredentialsScope.GLOBAL, serviceAccountCredentialId, "1Password Service Account Credential", Secret.fromString(System.getenv("OP_SA_TOKEN"))); - @Before - public void init() throws IOException { + @BeforeEach + void init(JenkinsRule j) throws IOException { + this.j = j; CredentialsProvider.lookupStores(j.jenkins) .iterator() .next() @@ -42,7 +43,7 @@ public void init() throws IOException { } @Test - public void testConfigFunction() throws Exception { + void testConfigFunction() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigFunction.groovy", Charset.defaultCharset()) @@ -55,7 +56,7 @@ public void testConfigFunction() throws Exception { } @Test - public void testConfigPipeline() throws Exception { + void testConfigPipeline() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigPipeline.groovy", Charset.defaultCharset()) @@ -68,7 +69,7 @@ public void testConfigPipeline() throws Exception { } @Test - public void testConfigGlobal() throws Exception { + void testConfigGlobal() throws Exception { OnePasswordGlobalConfig globalConfig = GlobalConfiguration.all().get(OnePasswordGlobalConfig.class); OnePasswordConfig config = new OnePasswordConfig(); config.setServiceAccountCredentialId(serviceAccountCredentialId); @@ -91,7 +92,7 @@ public void testConfigGlobal() throws Exception { } @Test - public void testConfigMergeTokenId() throws Exception { + void testConfigMergeTokenId() throws Exception { OnePasswordGlobalConfig globalConfig = GlobalConfiguration.all().get(OnePasswordGlobalConfig.class); OnePasswordConfig config = new OnePasswordConfig(); config.setServiceAccountCredentialId(serviceAccountCredentialId); @@ -113,7 +114,7 @@ public void testConfigMergeTokenId() throws Exception { } @Test - public void testConfigFromEnv() throws Exception { + void testConfigFromEnv() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigFromEnv.groovy", Charset.defaultCharset()) @@ -126,7 +127,7 @@ public void testConfigFromEnv() throws Exception { } @Test - public void testConfigPriorityToken() throws Exception { + void testConfigPriorityToken() throws Exception { WorkflowJob project = j.createProject(WorkflowJob.class); project.setDefinition(new CpsFlowDefinition(readFile(basePath + "testConfigPriorityToken.groovy", Charset.defaultCharset()) @@ -139,7 +140,7 @@ public void testConfigPriorityToken() throws Exception { } @Test - public void testConfigNoToken() throws Exception { + void testConfigNoToken() throws Exception { CredentialsProvider.lookupStores(j.jenkins) .iterator() .next() diff --git a/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordFolderConfigConnectTest.java b/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordFolderConfigConnectTest.java index 3cab55b..038ae1d 100644 --- a/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordFolderConfigConnectTest.java +++ b/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordFolderConfigConnectTest.java @@ -9,20 +9,20 @@ import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.jenkinsci.plugins.workflow.job.WorkflowRun; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.jvnet.hudson.test.JenkinsRule; +import org.jvnet.hudson.test.junit.jupiter.WithJenkins; import java.io.IOException; import java.nio.charset.Charset; import static com.onepassword.jenkins.plugins.util.TestConstants.*; -public class OnePasswordFolderConfigConnectTest { +@WithJenkins +class OnePasswordFolderConfigConnectTest { - @Rule - public JenkinsRule j = new JenkinsRule(); + private JenkinsRule j; private final String basePath = "src/test/resources/com/onepassword/jenkins/plugins/config/connect/"; @@ -31,8 +31,9 @@ public class OnePasswordFolderConfigConnectTest { CredentialsScope.GLOBAL, "connect-credential-id", "1Password Connect Credential", Secret.fromString(System.getenv("OP_TOKEN"))); - @Before - public void init() throws IOException { + @BeforeEach + void init(JenkinsRule j) throws IOException { + this.j = j; CredentialsProvider.lookupStores(j.jenkins) .iterator() .next() @@ -40,7 +41,7 @@ public void init() throws IOException { } @Test - public void testConfigFolder() throws Exception { + void testConfigFolder() throws Exception { Folder folder = j.createProject(Folder.class); OnePasswordConfig config = new OnePasswordConfig(); config.setConnectHost(TEST_CONNECT_HOST); diff --git a/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordFolderConfigServiceAccountTest.java b/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordFolderConfigServiceAccountTest.java index 4114a83..fb26594 100644 --- a/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordFolderConfigServiceAccountTest.java +++ b/src/test/java/com/onepassword/jenkins/plugins/config/OnePasswordFolderConfigServiceAccountTest.java @@ -9,20 +9,20 @@ import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.jenkinsci.plugins.workflow.job.WorkflowRun; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.jvnet.hudson.test.JenkinsRule; +import org.jvnet.hudson.test.junit.jupiter.WithJenkins; import java.io.IOException; import java.nio.charset.Charset; import static com.onepassword.jenkins.plugins.util.TestConstants.*; -public class OnePasswordFolderConfigServiceAccountTest { +@WithJenkins +class OnePasswordFolderConfigServiceAccountTest { - @Rule - public JenkinsRule j = new JenkinsRule(); + private JenkinsRule j; private final String basePath = "src/test/resources/com/onepassword/jenkins/plugins/config/serviceaccount/"; @@ -31,8 +31,9 @@ public class OnePasswordFolderConfigServiceAccountTest { CredentialsScope.GLOBAL, "service-account-credential-id", "1Password Service Account Credential", Secret.fromString(System.getenv("OP_SA_TOKEN"))); - @Before - public void init() throws IOException { + @BeforeEach + void init(JenkinsRule j) throws IOException { + this.j = j; CredentialsProvider.lookupStores(j.jenkins) .iterator() .next() @@ -40,7 +41,7 @@ public void init() throws IOException { } @Test - public void testConfigFolder() throws Exception { + void testConfigFolder() throws Exception { Folder folder = j.createProject(Folder.class); OnePasswordConfig config = new OnePasswordConfig(); config.setServiceAccountCredentialId("service-account-credential-id");