@@ -44,19 +44,24 @@ dependencies {
4444 api ' javax.xml.bind:jaxb-api:2.2.2'
4545
4646 testImplementation project(' :test:fixtures:s3-fixture' )
47- yamlRestTestImplementation project(" :test:framework" )
48- yamlRestTestImplementation project(' :test:fixtures:s3-fixture' )
49- yamlRestTestImplementation project(' :test:fixtures:ec2-imds-fixture' )
50- yamlRestTestImplementation project(' :test:fixtures:aws-sts-fixture' )
51- yamlRestTestImplementation project(' :test:fixtures:minio-fixture' )
52- internalClusterTestImplementation project(' :test:fixtures:minio-fixture' )
5347
54- javaRestTestImplementation project(" :test:framework" )
55- javaRestTestImplementation project(' :test:fixtures:s3-fixture' )
56- javaRestTestImplementation project(' :modules:repository-s3' )
48+ internalClusterTestImplementation project(' :test:fixtures:minio-fixture' )
49+ internalClusterTestRuntimeOnly " org.slf4j:slf4j-simple:${ versions.slf4j} "
5750
51+ yamlRestTestImplementation project(' :modules:repository-s3' )
52+ yamlRestTestImplementation project(' :test:fixtures:s3-fixture' )
53+ yamlRestTestImplementation project(' :test:fixtures:testcontainer-utils' )
54+ yamlRestTestImplementation project(' :test:framework' )
5855 yamlRestTestRuntimeOnly " org.slf4j:slf4j-simple:${ versions.slf4j} "
59- internalClusterTestRuntimeOnly " org.slf4j:slf4j-simple:${ versions.slf4j} "
56+
57+ javaRestTestImplementation project(' :modules:repository-s3' )
58+ javaRestTestImplementation project(' :test:fixtures:aws-sts-fixture' )
59+ javaRestTestImplementation project(' :test:fixtures:ec2-imds-fixture' )
60+ javaRestTestImplementation project(' :test:fixtures:minio-fixture' )
61+ javaRestTestImplementation project(' :test:fixtures:s3-fixture' )
62+ javaRestTestImplementation project(' :test:fixtures:testcontainer-utils' )
63+ javaRestTestImplementation project(' :test:framework' )
64+ javaRestTestRuntimeOnly " org.slf4j:slf4j-simple:${ versions.slf4j} "
6065}
6166
6267restResources {
@@ -83,90 +88,25 @@ def testRepositoryCreds = tasks.register("testRepositoryCreds", Test) {
8388 testClassesDirs = sourceSets. test. output. classesDirs
8489}
8590
86- tasks. named(' check' ). configure {
87- dependsOn(testRepositoryCreds)
88- }
89-
9091tasks. named(' test' ). configure {
9192 // this is tested explicitly in separate test tasks
9293 exclude ' **/RepositoryCredentialsTests.class'
9394}
9495
9596boolean useFixture = false
96-
97- // We test against two repositories, one which uses the usual two-part "permanent" credentials and
98- // the other which uses three-part "temporary" or "session" credentials.
99-
10097String s3PermanentAccessKey = System . getenv(" amazon_s3_access_key" )
10198String s3PermanentSecretKey = System . getenv(" amazon_s3_secret_key" )
10299String s3PermanentBucket = System . getenv(" amazon_s3_bucket" )
103100String s3PermanentBasePath = System . getenv(" amazon_s3_base_path" )
104101
105- String s3TemporaryAccessKey = System . getenv(" amazon_s3_access_key_temporary" )
106- String s3TemporarySecretKey = System . getenv(" amazon_s3_secret_key_temporary" )
107- String s3TemporarySessionToken = System . getenv(" amazon_s3_session_token_temporary" )
108- String s3TemporaryBucket = System . getenv(" amazon_s3_bucket_temporary" )
109- String s3TemporaryBasePath = System . getenv(" amazon_s3_base_path_temporary" )
110-
111- String s3EC2Bucket = System . getenv(" amazon_s3_bucket_ec2" )
112- String s3EC2BasePath = System . getenv(" amazon_s3_base_path_ec2" )
113-
114- String s3ECSBucket = System . getenv(" amazon_s3_bucket_ecs" )
115- String s3ECSBasePath = System . getenv(" amazon_s3_base_path_ecs" )
116-
117- String s3STSBucket = System . getenv(" amazon_s3_bucket_sts" )
118- String s3STSBasePath = System . getenv(" amazon_s3_base_path_sts" )
119-
120- boolean s3DisableChunkedEncoding = buildParams. random. nextBoolean()
121-
122- // If all these variables are missing then we are testing against the internal fixture instead, which has the following
123- // credentials hard-coded in.
102+ // If all these variables are missing then we are testing against the internal fixture instead, which has the following credentials hard-coded in.
124103
125104if (! s3PermanentAccessKey && ! s3PermanentSecretKey && ! s3PermanentBucket && ! s3PermanentBasePath) {
105+ useFixture = true
126106 s3PermanentAccessKey = ' s3_test_access_key'
127107 s3PermanentSecretKey = ' s3_test_secret_key'
128108 s3PermanentBucket = ' bucket'
129109 s3PermanentBasePath = ' base_path'
130- useFixture = true
131- }
132- if (! s3TemporaryAccessKey && ! s3TemporarySecretKey && ! s3TemporaryBucket && ! s3TemporaryBasePath && ! s3TemporarySessionToken) {
133- s3TemporaryAccessKey = ' session_token_access_key'
134- s3TemporarySecretKey = ' session_token_secret_key'
135- s3TemporaryBucket = ' session_token_bucket'
136- s3TemporaryBasePath = ' session_token_base_path'
137- }
138-
139- if (! s3EC2Bucket && ! s3EC2BasePath && ! s3ECSBucket && ! s3ECSBasePath) {
140- s3EC2Bucket = ' ec2_bucket'
141- s3EC2BasePath = ' ec2_base_path'
142- s3ECSBucket = ' ecs_bucket'
143- s3ECSBasePath = ' ecs_base_path'
144- }
145-
146- if (! s3STSBucket && ! s3STSBasePath) {
147- s3STSBucket = ' sts_bucket'
148- s3STSBasePath = ' sts_base_path'
149- }
150-
151- tasks. named(" processYamlRestTestResources" ). configure {
152- from(" src/test/resources" ) {
153- include " aws-web-identity-token-file"
154- }
155- Map<String , Object > expansions = [
156- ' permanent_bucket' : s3PermanentBucket,
157- ' permanent_base_path' : s3PermanentBasePath + " _integration_tests" ,
158- ' temporary_bucket' : s3TemporaryBucket,
159- ' temporary_base_path' : s3TemporaryBasePath + " _integration_tests" ,
160- ' ec2_bucket' : s3EC2Bucket,
161- ' ec2_base_path' : s3EC2BasePath,
162- ' ecs_bucket' : s3ECSBucket,
163- ' ecs_base_path' : s3ECSBasePath,
164- ' sts_bucket' : s3STSBucket,
165- ' sts_base_path' : s3STSBasePath,
166- ' disable_chunked_encoding' : s3DisableChunkedEncoding
167- ]
168- inputs. properties(expansions)
169- filter(" tokens" : expansions. collectEntries {k , v -> [k, v. toString()]} /* must be a map of strings */ , ReplaceTokens . class)
170110}
171111
172112tasks. named(" internalClusterTest" ). configure {
@@ -176,36 +116,21 @@ tasks.named("internalClusterTest").configure {
176116 systemProperty ' es.insecure_network_trace_enabled' , ' true'
177117}
178118
179- tasks. named(" yamlRestTest" ). configure {
180- systemProperty(" s3PermanentAccessKey" , s3PermanentAccessKey)
181- systemProperty(" s3PermanentSecretKey" , s3PermanentSecretKey)
182- systemProperty(" s3TemporaryAccessKey" , s3TemporaryAccessKey)
183- systemProperty(" s3TemporarySecretKey" , s3TemporarySecretKey)
184- systemProperty(" s3EC2AccessKey" , s3PermanentAccessKey)
185-
186- // ideally we could resolve an env path in cluster config as resource similar to configuring a config file
187- // not sure how common this is, but it would be nice to support
188- File awsWebIdentityTokenExternalLocation = file(' src/test/resources/aws-web-identity-token-file' )
189- // The web identity token can be read only from the plugin config directory because of security restrictions
190- // Ideally we would create a symlink, but extraConfigFile doesn't support it
191- nonInputProperties. systemProperty(" awsWebIdentityTokenExternalLocation" , awsWebIdentityTokenExternalLocation. getAbsolutePath())
192- }
193-
194- // 3rd Party Tests
119+ // 3rd Party Tests, i.e. testing against a real S3 repository
195120tasks. register(" s3ThirdPartyTest" , Test ) {
196121 SourceSetContainer sourceSets = project. getExtensions(). getByType(SourceSetContainer . class);
197122 SourceSet internalTestSourceSet = sourceSets. getByName(InternalClusterTestPlugin . SOURCE_SET_NAME )
198123 setTestClassesDirs(internalTestSourceSet. getOutput(). getClassesDirs())
199124 setClasspath(internalTestSourceSet. getRuntimeClasspath())
200125 include ' **/S3RepositoryThirdPartyTests.class'
201126 systemProperty(" tests.use.fixture" , Boolean . toString(useFixture))
202-
203- // test container accesses ~/.testcontainers.properties read
204- systemProperty " tests.security.manager" , " false"
205127 systemProperty ' test.s3.account' , s3PermanentAccessKey
206128 systemProperty ' test.s3.key' , s3PermanentSecretKey
207129 systemProperty ' test.s3.bucket' , s3PermanentBucket
208130 nonInputProperties. systemProperty ' test.s3.base' , s3PermanentBasePath + " _third_party_tests_" + buildParams. testSeed
131+
132+ // test container accesses ~/.testcontainers.properties read
133+ systemProperty " tests.security.manager" , " false"
209134}
210135
211136tasks. named(" thirdPartyAudit" ). configure {
@@ -242,5 +167,6 @@ tasks.named("thirdPartyAudit").configure {
242167
243168tasks. named(" check" ). configure {
244169 dependsOn(tasks. withType(Test ))
170+ dependsOn(testRepositoryCreds)
245171}
246172
0 commit comments