Search in sources :

Example 1 with AllowedMethods

use of com.amazonaws.services.s3.model.CORSRule.AllowedMethods in project cloud-pipeline by epam.

the class S3StorageProviderTest method setUp.

@Before
public void setUp() {
    when(bucket.getName()).thenReturn(bucketName);
    when(amazonClient.createBucket(any(CreateBucketRequest.class))).thenReturn(bucket);
    when(s3Helper.getDefaultS3Client()).thenReturn(amazonClient);
    AwsRegion region = new AwsRegion();
    region.setId(REGION_ID);
    region.setAwsRegionName("us-east-1");
    region.setCorsRules("[" + "  {" + "    \"AllowedOrigins\": [\"string\"]," + "    \"AllowedMethods\": [\"PUT\", \"GET\"]," + "    \"AllowedHeaders\": [\"string\"]," + "    \"MaxAgeSeconds\": 3000," + "    \"ExposeHeaders\": [\"string\"]" + "  }" + "]");
    when(awsRegionManager.getAwsRegion(any())).thenReturn(region);
    doReturn(s3Helper).when(s3StorageProvider).getS3Helper(any());
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) CreateBucketRequest(com.amazonaws.services.s3.model.CreateBucketRequest) Before(org.junit.Before)

Example 2 with AllowedMethods

use of com.amazonaws.services.s3.model.CORSRule.AllowedMethods in project aws-sdk-android by aws-amplify.

the class BucketConfigurationXmlFactory method writeRule.

private void writeRule(XmlWriter xml, CORSRule rule) {
    xml.start("CORSRule");
    if (rule.getId() != null) {
        xml.start("ID").value(rule.getId()).end();
    }
    if (rule.getAllowedOrigins() != null) {
        for (final String origin : rule.getAllowedOrigins()) {
            xml.start("AllowedOrigin").value(origin).end();
        }
    }
    if (rule.getAllowedMethods() != null) {
        for (final AllowedMethods method : rule.getAllowedMethods()) {
            xml.start("AllowedMethod").value(method.toString()).end();
        }
    }
    if (rule.getMaxAgeSeconds() != 0) {
        xml.start("MaxAgeSeconds").value(Integer.toString(rule.getMaxAgeSeconds())).end();
    }
    if (rule.getExposedHeaders() != null) {
        for (final String header : rule.getExposedHeaders()) {
            xml.start("ExposeHeader").value(header).end();
        }
    }
    if (rule.getAllowedHeaders() != null) {
        for (final String header : rule.getAllowedHeaders()) {
            xml.start("AllowedHeader").value(header).end();
        }
    }
    // </CORSRule>
    xml.end();
}
Also used : AllowedMethods(com.amazonaws.services.s3.model.CORSRule.AllowedMethods)

Aggregations

AllowedMethods (com.amazonaws.services.s3.model.CORSRule.AllowedMethods)1 CreateBucketRequest (com.amazonaws.services.s3.model.CreateBucketRequest)1 AwsRegion (com.epam.pipeline.entity.region.AwsRegion)1 Before (org.junit.Before)1