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