Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded to AWS SDK version used by MariaDB #219

Merged
merged 7 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ group=com.agorapulse
micronautVersion = 4.2.0
micronautGradlePluginVersion = 4.2.0
gruVersion = 2.0.5
awsSdkVersion = 1.12.299
awsSdk2Version = 2.18.40
awsSdkVersion = 1.12.686
awsSdk2Version = 2.21.1
awsLambdaRuntimeVersion=2.5.0
testcontainersVersion = 1.17.3
kordampVersion=0.53.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ dependencies {
api "software.amazon.awssdk:sns:$project.awsSdk2Version"
api "software.amazon.awssdk:sqs:$project.awsSdk2Version"
api "software.amazon.awssdk:sts:$project.awsSdk2Version"
api "software.amazon.awssdk:aws-query-protocol:$project.awsSdk2Version"

api group: 'com.amazonaws', name: 'amazon-dax-client', version: '1.0.205044.0'
api group: 'com.amazonaws', name: 'aws-lambda-java-events', version: '2.2.7'
api group: 'com.amazonaws', name: 'amazon-dax-client', version: '1.0.230341.0'
api group: 'com.amazonaws', name: 'aws-lambda-java-events', version: '2.2.9'
api group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-cbor', version: project['jackson.datatype.version']
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@
import io.micronaut.context.annotation.ConfigurationProperties;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@ConfigurationProperties("localstack")
public class LocalstackContainerConfiguration extends AbstractContainerConfiguration {

public static final Map<String, String> ALWAYS_PRESENT_ENV = Map.of(
"SQS_ENDPOINT_STRATEGY", "dynamic"
);

public static final String DEFAULT_IMAGE = "localstack/localstack";
public static final String DEFAULT_TAG = "1.3.0";
public static final String DEFAULT_TAG = "3.2.0";

public LocalstackContainerConfiguration() {
setImage(DEFAULT_IMAGE);
Expand All @@ -43,4 +49,10 @@ public void setServices(List<String> services) {
this.services = services;
}

@Override
public Map<String, String> getEnv() {
Map<String, String> allEnv = new HashMap<>(super.getEnv());
ALWAYS_PRESENT_ENV.forEach(allEnv::putIfAbsent);
return allEnv;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
localstack:
services: lambda
services: lambda,cloudwatchlogs
shared: true
env:
PROVIDER_OVERRIDE_LAMBDA: asf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,12 @@
import java.time.Instant;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class DefaultSimpleStorageService implements SimpleStorageService {

private static final Logger LOGGER = LoggerFactory.getLogger(DefaultSimpleStorageService.class);
private static final String ALL_USERS = "http://acs.amazonaws.com/groups/global/AllUsers";
private static final String AUTHENTICATED_USERS = "http://acs.amazonaws.com/groups/global/AuthenticatedUsers";
private static final String READ = "READ";

private final S3Client s3;
private final S3Presigner presigner;
private final String defaultBucketName;
Expand Down Expand Up @@ -218,7 +213,6 @@ public String moveObject(String sourceBucketName, String sourceKey, String desti
GetObjectAclResponse acl = s3.getObjectAcl(b -> b.bucket(sourceBucketName).key(sourceKey));
s3.putObjectAcl(b -> {
b.bucket(destinationBucketName).key(destinationKey).accessControlPolicy(p -> p.owner(acl.owner()).grants(acl.grants()));
extractCannedAcl(acl.grants()).ifPresent(b::acl);
});

s3.deleteObject(b -> b.bucket(sourceBucketName).key(sourceKey));
Expand All @@ -230,18 +224,4 @@ public String moveObject(String sourceBucketName, String sourceKey, String desti
}
}

private static Optional<ObjectCannedACL> extractCannedAcl(List<Grant> grants) {
for (Grant grant : grants) {
if (READ.equals(grant.permissionAsString())) {
if (ALL_USERS.equals(grant.grantee().uri())) {
return Optional.of(ObjectCannedACL.PUBLIC_READ);
}
if (AUTHENTICATED_USERS.equals(grant.grantee().uri())) {
return Optional.of(ObjectCannedACL.AUTHENTICATED_READ);
}
}
}
return Optional.empty();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SimpleStorageServiceSpec extends Specification {
}

@Unroll
void 'move object created with canned acl #desiredAcl'() {
void 'move object created with canned acl #desiredAcl'(ObjectCannedACL desiredAcl) {
when:
String newKey = 'mix/moved-' + desiredAcl
String oldKey = 'mix/to-be-moved-' + desiredAcl
Expand All @@ -172,9 +172,6 @@ class SimpleStorageServiceSpec extends Specification {
amazonS3.getObjectTagging { it.bucket(MY_BUCKET).key(newKey) }
.tagSet()
.any { it.key() == 'foo' && it.value() == 'bar' }

!service.exists(oldKey)

when:
GetObjectAclResponse newAcls = amazonS3.getObjectAcl { it.bucket(MY_BUCKET).key(newKey) }
then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ dependencies {
implementation 'io.micronaut:micronaut-jackson-databind'

testImplementation project(':micronaut-amazon-awssdk-integration-testing')
testImplementation project(':micronaut-amazon-awssdk-sqs')
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/
package com.agorapulse.micronaut.amazon.awssdk.sns

import com.agorapulse.micronaut.amazon.awssdk.sqs.SimpleQueueService
import io.micronaut.context.annotation.Property
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import spock.lang.PendingFeature
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Stepwise
Expand All @@ -37,11 +37,13 @@ import jakarta.inject.Inject
@Property(name = 'aws.sns.ios-sandbox.arn', value = IOS_SANDBOX_APP_ARN)
@Property(name = 'aws.sns.android.arn', value = ANDROID_APP_ARN)
@Property(name = 'aws.sns.amazon.arn', value = AMAZON_APP_ARN)
@Property(name = 'aws.sqs.queue', value = TEST_QUEUE)
class SimpleNotificationServiceSpec extends Specification {

// end::header[]

private static final String TEST_TOPIC = 'TestTopic'
private static final String TEST_QUEUE = 'TestQueue'
private static final String IOS_APP_ARN = 'arn:aws:sns:us-east-1:000000000000:app/APNS/IOS-APP'
private static final String IOS_SANDBOX_APP_ARN = 'arn:aws:sns:us-east-1:000000000000:app/APNS_SANDBOX/IOS-APP'
private static final String ANDROID_APP_ARN = 'arn:aws:sns:us-east-1:000000000000:app/GCM/ANDROID-APP'
Expand All @@ -52,6 +54,8 @@ class SimpleNotificationServiceSpec extends Specification {
// end::setup[]
@Inject SimpleNotificationServiceConfiguration configuration

@Inject SimpleQueueService simpleQueueService

@Shared String androidEndpointArn
@Shared String amazonEndpointArn
@Shared String iosEndpointArn
Expand All @@ -64,6 +68,8 @@ class SimpleNotificationServiceSpec extends Specification {
service.createIosApplication('IOS-APP', 'API-KEY', 'fake-cert', true)
service.createAndroidApplication('ANDROID-APP', 'API-KEY')
service.createAmazonApplication('AMAZON-APP', 'API-KEY', 'API-SECRET')

simpleQueueService.createQueue(TEST_QUEUE)
}

void 'new topic'() {
Expand Down Expand Up @@ -125,7 +131,6 @@ class SimpleNotificationServiceSpec extends Specification {
service.registerIosSandboxDevice('ANOTHER-IOS-SANDBOX-TOKEN')
}

@PendingFeature (reason = 'Needs to be tested with real SNS')
void 'register iOS sandbox device with the same token'() {
expect:
iosSandboxEndpointArn == service.createPlatformEndpoint(configuration.iosSandbox.arn, 'IOS-SANDBOX-TOKEN')
Expand Down Expand Up @@ -208,7 +213,7 @@ class SimpleNotificationServiceSpec extends Specification {

void 'subscribe to the queue'() {
when:
subscriptionArn = service.subscribeTopicWithQueue(topicArn, 'fake-queue-arn')
subscriptionArn = service.subscribeTopicWithQueue(topicArn, simpleQueueService.getQueueArn(TEST_QUEUE))
then:
subscriptionArn
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
localstack:
services: sns
services: sns,sqs
shared: true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
localstack:
services: lambda
services: lambda,cloudwatchlogs
shared: true
env:
PROVIDER_OVERRIDE_LAMBDA: asf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.agorapulse.micronaut.aws.sns

import io.micronaut.context.annotation.Property
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import spock.lang.PendingFeature
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Stepwise
Expand Down Expand Up @@ -89,9 +88,6 @@ class SimpleNotificationServiceSpec extends Specification {
endpointArn == newEndpointArn
}

@PendingFeature(
reason = 'GCM moved int Firebase Console, latest Localstack fails with "Invalid parameter: Attributes Reason: Platform credentials are invalid"'
)
void 'publish direct'() {
when:
String messageId = service.sendAndroidAppNotification(endpointArn, [message: 'Hello'], 'key')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
localstack:
services: sqs
shared: true

env:
DEBUG: 1
aws:
sqs:
tags:
Expand Down
Loading