Skip to content

Commit f6d0b67

Browse files
committed
Remove missed occurence of FileOnMasterKeyStoreSource
Adapt to jenkinsci/credentials-plugin#540
1 parent 6288482 commit f6d0b67

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/CertificateMultiBindingTest.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ public void basicsPipeline() throws Exception {
148148
String alias = "androiddebugkey";
149149
String password = "android";
150150
StandardCertificateCredentials c = new CertificateCredentialsImpl(CredentialsScope.GLOBAL, "my-certificate", alias,
151-
password, new CertificateCredentialsImpl.FileOnMasterKeyStoreSource(certificate.getAbsolutePath()));
151+
password, new CertificateCredentialsImpl.UploadedKeyStoreSource(new FileParameterValue.FileItemImpl(certificate), null));
152152
CredentialsProvider.lookupStores(r.jenkins).iterator().next().addCredentials(Domain.global(), c);
153153
// create the Pipeline job
154154
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
155-
String pipelineScript = IOUtils.toString(getTestResourceInputStream("basicsPipeline-Jenkinsfile"), StandardCharsets.UTF_8);
155+
String pipelineScript = getTestResourceAsUTF8String("basicsPipeline-Jenkinsfile");
156156
p.setDefinition(new CpsFlowDefinition(pipelineScript, true));
157157
// copy resources into workspace
158158
FilePath workspace = r.jenkins.getWorkspaceFor(p);
@@ -170,13 +170,20 @@ private InputStream getTestResourceInputStream(String fileName) {
170170
return getClass().getResourceAsStream(getClass().getSimpleName() + "/" + fileName);
171171
}
172172

173+
private String getTestResourceAsUTF8String(String resourceName) throws IOException {
174+
try (InputStream is = getTestResourceInputStream(resourceName)) {
175+
return IOUtils.toString(is, StandardCharsets.UTF_8);
176+
}
177+
}
178+
173179
private FilePath copyTestResourceIntoWorkspace(FilePath workspace, String fileName, int mask)
174180
throws IOException, InterruptedException {
175-
InputStream in = getTestResourceInputStream(fileName);
176-
FilePath f = workspace.child(fileName);
177-
f.copyFrom(in);
178-
f.chmod(mask);
179-
return f;
181+
try (InputStream in = getTestResourceInputStream(fileName)) {
182+
FilePath f = workspace.child(fileName);
183+
f.copyFrom(in);
184+
f.chmod(mask);
185+
return f;
186+
}
180187
}
181188

182189
}

0 commit comments

Comments
 (0)