Skip to content

Commit 23bdcbd

Browse files
desokroshanKarthikeyan
authored andcommitted
Fixes for s3 test failures (#756)
* Fixes for s3 test failures * Update config.yml * Update config.yml
1 parent 759f122 commit 23bdcbd

File tree

5 files changed

+53
-10
lines changed

5 files changed

+53
-10
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<DeleteResult>
3+
<Deleted>
4+
<Key>object1</Key>
5+
<VersionId>123</VersionId>
6+
</Deleted>
7+
<Error>
8+
<Key>object2</Key>
9+
<Code>AccessDenied</Code>
10+
<Message>Access Denied</Message>
11+
</Error>
12+
</DeleteResult>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<DeleteResult>
3+
<Deleted>
4+
<Key>key1</Key>
5+
<VersionId>Version1</VersionId>
6+
</Deleted>
7+
<Error>
8+
<Key>key2</Key>
9+
<VersionId>Version2</VersionId>
10+
<Code>Code</Code>
11+
<Message>Message</Message>
12+
</Error>
13+
<Deleted>
14+
<Key>key3</Key>
15+
<DeleteMarker>true</DeleteMarker>
16+
<DeleteMarkerVersionId>Version3</DeleteMarkerVersionId>
17+
</Deleted>
18+
</DeleteResult>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Version":"2008-10-17",
3+
"Statement":[{
4+
"Sid":"AddPerm",
5+
"Effect":"Allow",
6+
"Principal": {
7+
"AWS": "*"
8+
},
9+
"Action":["s3:GetObject"],
10+
"Resource":["arn:aws:s3:::@BUCKET_NAME@/*"]
11+
}]
12+
}

aws-android-sdk-s3-test/src/androidTest/java/com/amazonaws/services/s3/BucketPolicyIntegrationTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package com.amazonaws.services.s3;
1717

18+
import android.support.test.InstrumentationRegistry;
19+
1820
import static org.junit.Assert.assertNotNull;
1921
import static org.junit.Assert.assertNull;
2022
import static org.junit.Assert.assertTrue;
@@ -27,6 +29,8 @@
2729
import org.junit.Before;
2830
import org.junit.Test;
2931

32+
import java.io.InputStream;
33+
3034
/**
3135
* Integration tests for S3 bucket policy operations.
3236
*/
@@ -36,7 +40,7 @@ public class BucketPolicyIntegrationTest extends S3IntegrationTestBase {
3640
private final String bucketName = "java-bucket-policy-integ-test-" + System.currentTimeMillis();
3741

3842
/** Path to the sample policy for this test */
39-
private static final String POLICY_FILE = "/com/amazonaws/services/s3/samplePolicy.json";
43+
private static final String POLICY_FILE = "samplePolicy.json";
4044

4145
/** Create bucket and wait for creation */
4246
@Before
@@ -58,7 +62,8 @@ public void tearDown() {
5862
/** Tests that we can get/put/delete bucket policies. */
5963
@Test
6064
public void testBucketPolicies() throws Exception {
61-
String policyText = IOUtils.toString(getClass().getResourceAsStream(POLICY_FILE));
65+
InputStream policyInputStream = InstrumentationRegistry.getContext().getResources().getAssets().open(POLICY_FILE);
66+
String policyText = IOUtils.toString(policyInputStream);
6267
policyText = replace(policyText, "@BUCKET_NAME@", bucketName);
6368

6469
// Verify that no policy exists yet

aws-android-sdk-s3-test/src/androidTest/java/com/amazonaws/services/s3/MultiObjectDeleteIntegrationTest.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package com.amazonaws.services.s3;
1717

18+
import android.support.test.InstrumentationRegistry;
19+
1820
import static org.junit.Assert.assertEquals;
1921
import static org.junit.Assert.assertFalse;
2022
import static org.junit.Assert.assertNull;
@@ -146,10 +148,7 @@ public void testErrorHandling() throws Exception {
146148

147149
DeleteObjectsResultUnmarshaller unmarshaller = new Unmarshallers.DeleteObjectsResultUnmarshaller();
148150
DeleteObjectsResponse response = unmarshaller
149-
.unmarshall(this
150-
.getClass()
151-
.getResourceAsStream(
152-
"/com/amazonaws/services/s3/multiObjectDelete/testResponses/errorResponse.xml"));
151+
.unmarshall(InstrumentationRegistry.getContext().getResources().getAssets().open("errorResponse.xml"));
153152

154153
assertEquals(1, response.getDeletedObjects().size());
155154
assertEquals(1, response.getErrors().size());
@@ -170,10 +169,7 @@ public void testErrorHandling() throws Exception {
170169
public void testFullServiceResponse() throws Exception {
171170
DeleteObjectsResultUnmarshaller unmarshaller = new Unmarshallers.DeleteObjectsResultUnmarshaller();
172171
DeleteObjectsResponse response = unmarshaller
173-
.unmarshall(this
174-
.getClass()
175-
.getResourceAsStream(
176-
"/com/amazonaws/services/s3/multiObjectDelete/testResponses/fullResponse.xml"));
172+
.unmarshall(InstrumentationRegistry.getContext().getResources().getAssets().open("fullResponse.xml"));
177173

178174
assertEquals(2, response.getDeletedObjects().size());
179175
assertEquals(1, response.getErrors().size());

0 commit comments

Comments
 (0)