mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test: reuse named storage overrides in service fixtures (#7194)
Complete the remaining AppSync and AWS Config fixture conversions requested separately in #6912. Preserve existing parked-write, retry, persistence and account-scoping assertions. The shared helper and AppConfig conversion are already on main. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> Signed-off-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
1 parent
5495c706fa
commit
a707cb3260
3 files changed
+10
-46
No files matched your search
@@ -1,13 +1,11 @@
|
||||
package io.github.hectorvent.floci.services.appsync;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.RequestContext;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.SchemaCreationWorker;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.SchemaRegistry;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.auth.LambdaAuthorizerCache;
|
||||
@@ -18,6 +16,7 @@ import io.github.hectorvent.floci.services.appsync.model.DomainName;
|
||||
import io.github.hectorvent.floci.services.appsync.model.FunctionConfiguration;
|
||||
import io.github.hectorvent.floci.services.appsync.model.GraphqlApi;
|
||||
import io.github.hectorvent.floci.services.appsync.model.SchemaCreationStatus;
|
||||
import io.github.hectorvent.floci.testing.InMemoryStorageFactory;
|
||||
import jakarta.enterprise.inject.Instance;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -412,19 +411,11 @@ class AppSyncServiceTest {
|
||||
@SuppressWarnings("unchecked")
|
||||
private AppSyncService newService(Clock clock, String baseUrl,
|
||||
AccountAwareStorageBackend<GraphqlApi> apiStore) {
|
||||
StorageFactory storageFactory = new StorageFactory(null, null) {
|
||||
@Override
|
||||
public <V> AccountAwareStorageBackend<V> create(String serviceName, String fileName,
|
||||
TypeReference<Map<String, V>> typeReference) {
|
||||
if ("appsync-apis.json".equals(fileName)) {
|
||||
return (AccountAwareStorageBackend<V>) apiStore;
|
||||
}
|
||||
if ("appsync-apikeys.json".equals(fileName) && apiKeyStoreOverride != null) {
|
||||
return (AccountAwareStorageBackend<V>) apiKeyStoreOverride;
|
||||
}
|
||||
return AccountAwareStorageBackend.inMemory("000000000000");
|
||||
}
|
||||
};
|
||||
InMemoryStorageFactory storageFactory = new InMemoryStorageFactory("000000000000")
|
||||
.withStore("appsync-apis.json", apiStore);
|
||||
if (apiKeyStoreOverride != null) {
|
||||
storageFactory.withStore("appsync-apikeys.json", apiKeyStoreOverride);
|
||||
}
|
||||
Instance<RequestContext> requestContext = mock(Instance.class);
|
||||
schemaRegistry = mock(SchemaRegistry.class);
|
||||
lambdaAuthorizerCache = new LambdaAuthorizerCache();
|
||||
|
||||
+2
-16
@@ -1,15 +1,11 @@
|
||||
package io.github.hectorvent.floci.services.configservice;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.core.storage.WriteProfile;
|
||||
import io.github.hectorvent.floci.services.configservice.model.AggregationAuthorization;
|
||||
import io.github.hectorvent.floci.services.configservice.model.ConformancePack;
|
||||
import io.github.hectorvent.floci.testing.InMemoryStorageFactory;
|
||||
import io.github.hectorvent.floci.testing.ParkingStore;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -237,17 +233,7 @@ class AwsConfigServiceAggregationAuthorizationTest {
|
||||
void aPackDeleteWaitsForAnUpdateAlreadyInProgress() throws Exception {
|
||||
ParkingStore<Map<String, ConformancePack>> packs = new ParkingStore<>();
|
||||
AwsConfigService service = new AwsConfigService(new RegionResolver(REGION, ACCOUNT),
|
||||
new StorageFactory(null, null) {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <V> AccountAwareStorageBackend<V> create(String serviceName, String fileName,
|
||||
TypeReference<Map<String, V>> typeReference, WriteProfile profile) {
|
||||
return fileName.equals("config-conformance-packs.json")
|
||||
? new AccountAwareStorageBackend<>((StorageBackend<String, V>) (Object) packs,
|
||||
null, ACCOUNT)
|
||||
: AccountAwareStorageBackend.inMemory(ACCOUNT);
|
||||
}
|
||||
});
|
||||
new InMemoryStorageFactory(ACCOUNT).withStore("config-conformance-packs.json", packs));
|
||||
service.initializeStorage();
|
||||
String arn = service.putConformancePack(REGION, "pack", "s3://bucket/v1.yaml", null)
|
||||
.conformancePackArn();
|
||||
|
||||
+2
-15
@@ -1,15 +1,12 @@
|
||||
package io.github.hectorvent.floci.services.configservice;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.core.storage.WriteProfile;
|
||||
import io.github.hectorvent.floci.services.configservice.model.ConfigRule;
|
||||
import io.github.hectorvent.floci.services.configservice.model.ConfigRuleSource;
|
||||
import io.github.hectorvent.floci.testing.InMemoryStorageFactory;
|
||||
import io.github.hectorvent.floci.testing.ParkingStore;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.function.Executable;
|
||||
@@ -230,17 +227,7 @@ class AwsConfigServiceTaggingTest {
|
||||
|
||||
private static AwsConfigService serviceWithTagStore(StorageBackend<String, Map<String, String>> tagStore) {
|
||||
AwsConfigService service = new AwsConfigService(new RegionResolver(REGION, ACCOUNT),
|
||||
new StorageFactory(null, null) {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <V> AccountAwareStorageBackend<V> create(String serviceName, String fileName,
|
||||
TypeReference<Map<String, V>> typeReference, WriteProfile profile) {
|
||||
return fileName.equals("config-tags.json")
|
||||
? new AccountAwareStorageBackend<>((StorageBackend<String, V>) (Object) tagStore,
|
||||
null, ACCOUNT)
|
||||
: AccountAwareStorageBackend.inMemory(ACCOUNT);
|
||||
}
|
||||
});
|
||||
new InMemoryStorageFactory(ACCOUNT).withStore("config-tags.json", tagStore));
|
||||
service.initializeStorage();
|
||||
return service;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user