Skip to content

Commit

Permalink
Merge pull request #116 from ferndem/feature/fd/update_library
Browse files Browse the repository at this point in the history
update library and replace deprecate method
  • Loading branch information
maxlaverse authored Feb 21, 2024
2 parents 2f5071a + a24e3e5 commit e844f40
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 21 deletions.
13 changes: 3 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

<name>Kubernetes CLI Plugin</name>
<url>https://github.com/jenkinsci/kubernetes-cli-plugin</url>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>kubernetes-cli</artifactId>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>
Expand All @@ -20,15 +19,13 @@
<hpi.compatibleSinceVersion>1.0.0</hpi.compatibleSinceVersion>

<!-- dependency versions -->
<jenkins.version>2.401.1</jenkins.version>
<jenkins.version>2.401.3</jenkins.version>
<bom.artifactId>bom-2.401.x</bom.artifactId>
<bom.version>2357.v1043f8578392</bom.version>
<bom.version>2555.v3190a_8a_c60c6</bom.version>

<!-- jenkins plugins versions -->
<jenkins-env-inject.version>2.3.0</jenkins-env-inject.version>
<jenkins-declarative.version>1.4.0</jenkins-declarative.version>
<jenkins-kubernetes-credentials.version>0.11</jenkins-kubernetes-credentials.version>


<!-- maven plugins versions -->
<maven-coveralls.version>4.3.0</maven-coveralls.version>

Expand Down Expand Up @@ -102,7 +99,6 @@
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>kubernetes-credentials</artifactId>
<version>${jenkins-kubernetes-credentials.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down Expand Up @@ -136,7 +132,6 @@
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-definition</artifactId>
<version>${jenkins-declarative.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -163,13 +158,11 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>docker-commons</artifactId>
<version>439.va_3cb_0a_6a_fb_29</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<version>2.6.6</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static ListBoxModel doFillCredentialsIdItems(@Nonnull @AncestorInPath Ite
return new StandardListBoxModel()
.includeEmptyValue()
.includeMatchingAs(
ACL.SYSTEM,
ACL.SYSTEM2,
item,
StandardCredentials.class,
URIRequirementBuilder.fromUri(serverUrl).build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public void testEnvVariableFormat() throws Exception {
assertBuildStatus(b, Result.SUCCESS);
String regExp = "Using temporary file '(.+).kube(.+)config'";
Pattern kubeConfigPathRegexp = Pattern.compile(regExp);
assertTrue("No line in the logs matched the regular expression '" + regExp + "': " + r.getLog(b),
kubeConfigPathRegexp.matcher(r.getLog(b)).find());
assertTrue("No line in the logs matched the regular expression '" + regExp + "': " + JenkinsRule.getLog(b),
kubeConfigPathRegexp.matcher(JenkinsRule.getLog(b)).find());
}

private void assertBuildStatus(WorkflowRun b, Result result) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.jenkinsci.plugins.envinject.EnvInjectBuildWrapper;
import org.jenkinsci.plugins.envinject.EnvInjectJobPropertyInfo;
import org.jenkinsci.plugins.kubernetes.cli.helpers.DummyCredentials;
import org.jenkinsci.plugins.matrixauth.AuthorizationType;
import org.jenkinsci.plugins.matrixauth.PermissionEntry;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
Expand Down Expand Up @@ -140,10 +142,10 @@ public void testListingCredentialsWithoutAncestorAndMissingPermissions() throws

r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
ProjectMatrixAuthorizationStrategy as = new ProjectMatrixAuthorizationStrategy();
as.add(Jenkins.READ, "user-not-enough-permissions");
as.add(Jenkins.READ, new PermissionEntry(AuthorizationType.EITHER, "user-not-enough-permissions"));
r.jenkins.setAuthorizationStrategy(as);

try (ACLContext unused = ACL.as(User.get("user-not-enough-permissions", true, null).impersonate())) {
try (ACLContext unused = ACL.as2(User.get("user-not-enough-permissions", true, null).impersonate2())) {
ListBoxModel options = d.doFillCredentialsIdItems(null, "", "1");
assertEquals("- current -", options.get(0).name);
assertEquals(1, options.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public static BaseStandardCredentials secretCredential(String credentialId) {

public static BaseStandardCredentials certificateCredential(String credentialId) {
byte[] storeFile = TestResourceLoader.loadAsByteArray("kubernetes.pkcs12");
CertificateCredentialsImpl.KeyStoreSource keyStoreSource = new CertificateCredentialsImpl.UploadedKeyStoreSource(
CertificateCredentialsImpl.KeyStoreSource keyStoreSource = new CertificateCredentialsImpl.UploadedKeyStoreSource(null,
SecretBytes.fromBytes(storeFile));
return new CertificateCredentialsImpl(CredentialsScope.GLOBAL, credentialId, "sample", PASSPHRASE,
keyStoreSource);
}

public static BaseStandardCredentials brokenCertificateCredential(String credentialId) {
byte[] storeFile = TestResourceLoader.loadAsByteArray("kubernetes.pkcs12");
CertificateCredentialsImpl.KeyStoreSource keyStoreSource = new CertificateCredentialsImpl.UploadedKeyStoreSource(
CertificateCredentialsImpl.KeyStoreSource keyStoreSource = new CertificateCredentialsImpl.UploadedKeyStoreSource(null,
SecretBytes.fromBytes(storeFile));
return new CertificateCredentialsImpl(CredentialsScope.GLOBAL, credentialId, "sample", "bad-passphrase",
keyStoreSource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

public class DummyTokenCredentialImpl extends UsernamePasswordCredentialsImpl implements TokenProducer {

public DummyTokenCredentialImpl(CredentialsScope scope, String id, String description, String username,
/**
*
*/
private static final long serialVersionUID = 1L;

public DummyTokenCredentialImpl(CredentialsScope scope, String id, String description, String username,
String password) {
super(scope, id, description, username, password);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

public class UnsupportedCredentialImpl extends BaseStandardCredentials {

public UnsupportedCredentialImpl(String id, String description) {
/**
*
*/
private static final long serialVersionUID = 1L;

public UnsupportedCredentialImpl(String id, String description) {
super(id, description);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class KubeConfigWriterAuthTest {

FilePath workspace;
Launcher mockLauncher;
AbstractBuild build;
AbstractBuild<?, ?> build;

private static String dumpBuilder(ConfigBuilder configBuilder) throws JsonProcessingException {
return Serialization.asYaml(configBuilder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class KubeConfigWriterBuilderTest {
public TemporaryFolder tempFolder = new TemporaryFolder();
FilePath workspace;
Launcher mockLauncher;
AbstractBuild build;
AbstractBuild<?, ?> build;

private static String dumpBuilder(ConfigBuilder configBuilder) throws JsonProcessingException {
return Serialization.asYaml(configBuilder.build());
Expand Down

0 comments on commit e844f40

Please sign in to comment.