forked from opensearch-project/opensearch-build-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PublishToArtifactsProdBucketLibTester.groovy
65 lines (57 loc) · 2.36 KB
/
PublishToArtifactsProdBucketLibTester.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
import static org.hamcrest.CoreMatchers.notNullValue
import static org.hamcrest.MatcherAssert.assertThat
class PublishToArtifactsProdBucketLibTester extends LibFunctionTester {
private String assumedRoleName
private String source
private String destination
private String signingPlatform
private String sigtype
private boolean overwrite
public PublishToArtifactsProdBucketLibTester(assumedRoleName, source, destination, signingPlatform, sigtype, overwrite) {
this.assumedRoleName = assumedRoleName
this.source = source
this.destination = destination
this.sigtype = sigtype
this.signingPlatform = signingPlatform
this.overwrite = overwrite
}
public PublishToArtifactsProdBucketLibTester(assumedRoleName, source, destination){
this.assumedRoleName = assumedRoleName
this.source = source
this.destination = destination
}
void configure(helper, binding){
helper.registerAllowedMethod("s3Upload", [Map])
binding.setVariable('GITHUB_BOT_TOKEN_NAME', 'github_bot_token_name')
helper.registerAllowedMethod('git', [Map])
helper.registerAllowedMethod('withCredentials', [Map, Closure], { args, closure ->
closure.delegate = delegate
return helper.callClosure(closure)
})
helper.registerAllowedMethod('withAWS', [Map, Closure], { args, closure ->
closure.delegate = delegate
return helper.callClosure(closure)
})
}
void parameterInvariantsAssertions(call){
assertThat(call.args.assumedRoleName.first(), notNullValue())
assertThat(call.args.source.first(), notNullValue())
assertThat(call.args.destination.first(), notNullValue())
}
boolean expectedParametersMatcher(call) {
return call.args.assumedRoleName.first().toString().equals(this.assumedRoleName)
&& call.args.source.first().toString().equals(this.source)
&& call.args.destination.first().toString().equals(this.destination)
}
String libFunctionName() {
return 'publishToArtifactsProdBucket'
}
}