Skip to content

Commit

Permalink
replace deprecate method
Browse files Browse the repository at this point in the history
  • Loading branch information
ferndem committed Feb 17, 2024
1 parent ad1faa3 commit a24e3e5
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 12 deletions.
1 change: 0 additions & 1 deletion 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 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 a24e3e5

Please sign in to comment.