mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(appconfig): serve legacy deployed configuration requests (#5658)
* fix(appconfig): serve legacy deployed configuration requests Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(appconfig): keep 404 for an unknown application or profile GetConfiguration now maps only a missing environment to BadRequestException, as a missing or undeployed environment was observed on AWS. An unknown application or configuration profile stays ResourceNotFoundException (404), as the API reference lists. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * docs(appconfig): note GetConfiguration error codes Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
This commit is contained in:
1 parent
f3e1cb6006
commit
91c67c69df
5 files changed
+414
-5
No files matched your search
@@ -543,4 +543,72 @@ class AppConfigTest {
|
||||
assertThat(response.versionLabel()).isEqualTo("1");
|
||||
assertThat(response.nextPollConfigurationToken()).isNotBlank();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(56)
|
||||
@DisplayName("GetConfiguration (deprecated) returns the deployed version by IDs or names")
|
||||
@SuppressWarnings("deprecation")
|
||||
void legacyGetConfigurationReturnsDeployedVersion() {
|
||||
String legacyAppName = TestFixtures.uniqueName("legacy-app");
|
||||
String legacyAppId = appConfig.createApplication(CreateApplicationRequest.builder()
|
||||
.name(legacyAppName).build()).id();
|
||||
try {
|
||||
String legacyEnvId = appConfig.createEnvironment(CreateEnvironmentRequest.builder()
|
||||
.applicationId(legacyAppId).name("legacy-env").build()).id();
|
||||
String legacyProfileId = appConfig.createConfigurationProfile(CreateConfigurationProfileRequest.builder()
|
||||
.applicationId(legacyAppId)
|
||||
.name("legacy-config")
|
||||
.locationUri("hosted")
|
||||
.type("AWS.Freeform")
|
||||
.build()).id();
|
||||
appConfig.createHostedConfigurationVersion(CreateHostedConfigurationVersionRequest.builder()
|
||||
.applicationId(legacyAppId)
|
||||
.configurationProfileId(legacyProfileId)
|
||||
.content(SdkBytes.fromUtf8String("{\"legacy\": true}"))
|
||||
.contentType("application/json")
|
||||
.build());
|
||||
appConfig.startDeployment(StartDeploymentRequest.builder()
|
||||
.applicationId(legacyAppId)
|
||||
.environmentId(legacyEnvId)
|
||||
.configurationProfileId(legacyProfileId)
|
||||
.configurationVersion("1")
|
||||
.deploymentStrategyId("AppConfig.AllAtOnce")
|
||||
.build());
|
||||
|
||||
GetConfigurationResponse byIds = appConfig.getConfiguration(GetConfigurationRequest.builder()
|
||||
.application(legacyAppId).environment(legacyEnvId).configuration(legacyProfileId)
|
||||
.clientId("sdk-client").build());
|
||||
assertThat(byIds.content().asUtf8String()).isEqualTo("{\"legacy\": true}");
|
||||
assertThat(byIds.contentType()).startsWith("application/json");
|
||||
assertThat(byIds.configurationVersion()).isEqualTo("1");
|
||||
|
||||
GetConfigurationResponse byNames = appConfig.getConfiguration(GetConfigurationRequest.builder()
|
||||
.application(legacyAppName).environment("legacy-env").configuration("legacy-config")
|
||||
.clientId("sdk-client").build());
|
||||
assertThat(byNames.content().asUtf8String()).isEqualTo("{\"legacy\": true}");
|
||||
assertThat(byNames.configurationVersion()).isEqualTo("1");
|
||||
|
||||
GetConfigurationResponse unchanged = appConfig.getConfiguration(GetConfigurationRequest.builder()
|
||||
.application(legacyAppId).environment(legacyEnvId).configuration(legacyProfileId)
|
||||
.clientId("sdk-client").clientConfigurationVersion("1").build());
|
||||
assertThat(unchanged.content().asByteArray()).isEmpty();
|
||||
assertThat(unchanged.configurationVersion()).isEqualTo("1");
|
||||
|
||||
// Qualified: the imported BadRequestException is AppConfigData's, this one is AppConfig's.
|
||||
assertThrows(software.amazon.awssdk.services.appconfig.model.BadRequestException.class,
|
||||
() -> appConfig.getConfiguration(GetConfigurationRequest.builder()
|
||||
.application(legacyAppId).environment("absent").configuration(legacyProfileId)
|
||||
.clientId("sdk-client").build()));
|
||||
assertThrows(ResourceNotFoundException.class,
|
||||
() -> appConfig.getConfiguration(GetConfigurationRequest.builder()
|
||||
.application(legacyAppId).environment(legacyEnvId).configuration("absent-config")
|
||||
.clientId("sdk-client").build()));
|
||||
} finally {
|
||||
try {
|
||||
appConfig.deleteApplication(DeleteApplicationRequest.builder().applicationId(legacyAppId).build());
|
||||
} catch (Exception ignored) {
|
||||
// Best-effort cleanup: the application name is unique, so a leftover cannot affect other tests.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,16 @@ The management plane allows you to create and manage applications, environments,
|
||||
- `StartDeployment`
|
||||
- `GetDeployment`
|
||||
- `ListDeployments` (`GET /applications/{ApplicationId}/environments/{EnvironmentId}/deployments`)
|
||||
- `GetConfiguration` (deprecated by AWS in favor of the [data plane](#data-plane))
|
||||
|
||||
`GetConfiguration` accepts application, environment and configuration profile names or IDs, and requires
|
||||
`client_id`. It returns the deployed version's content with its `Content-Type` and `Configuration-Version`;
|
||||
feature flags are resolved as on the [data plane](#data-plane), including Ion for a caller that accepts it.
|
||||
A `client_configuration_version` equal to the deployed version returns HTTP 200 with an empty body.
|
||||
A missing or undeployed environment returns `BadRequestException`; an unknown application or configuration profile
|
||||
returns `ResourceNotFoundException`.
|
||||
Only hosted configurations are served: a deployed version with no hosted configuration version behind it,
|
||||
such as one from an S3 or SSM source, returns `ResourceNotFoundException`.
|
||||
|
||||
## Data Plane (AppConfigData) {#data-plane}
|
||||
|
||||
|
||||
+33
-1
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.services.appconfig.AppConfigDataService.LegacyConfiguration;
|
||||
import io.github.hectorvent.floci.services.appconfig.model.Application;
|
||||
import io.github.hectorvent.floci.services.appconfig.model.ConfigurationProfile;
|
||||
import io.github.hectorvent.floci.services.appconfig.model.Deployment;
|
||||
@@ -21,8 +22,10 @@ import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.UriInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -33,11 +36,14 @@ import java.util.Map;
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class AppConfigController {
|
||||
private final AppConfigService service;
|
||||
private final AppConfigDataService dataService;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Inject
|
||||
public AppConfigController(AppConfigService service, ObjectMapper objectMapper) {
|
||||
public AppConfigController(AppConfigService service, AppConfigDataService dataService,
|
||||
ObjectMapper objectMapper) {
|
||||
this.service = service;
|
||||
this.dataService = dataService;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@@ -268,4 +274,30 @@ public class AppConfigController {
|
||||
public Response getDeployment(@PathParam("appId") String appId, @PathParam("envId") String envId, @PathParam("deploymentNumber") int deploymentNumber) {
|
||||
return Response.ok(service.getDeployment(appId, envId, deploymentNumber)).build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── Configuration ────────────────────────────
|
||||
|
||||
// The deprecated GetConfiguration: superseded by AppConfigData, but still an AppConfig operation.
|
||||
// The response type comes from the stored version (Ion for variant flags when Accept asks for it),
|
||||
// never from negotiation, so a non-JSON Accept header is not refused.
|
||||
@GET
|
||||
@Path("/applications/{appId}/environments/{envId}/configurations/{configuration}")
|
||||
@Produces(MediaType.WILDCARD)
|
||||
public Response getConfiguration(@PathParam("appId") String appId,
|
||||
@PathParam("envId") String envId,
|
||||
@PathParam("configuration") String configuration,
|
||||
@QueryParam("client_id") String clientId,
|
||||
@HeaderParam("Accept") String accept,
|
||||
@Context UriInfo uriInfo) {
|
||||
// Read raw: @QueryParam turns an empty value into null, but AWS rejects an empty version.
|
||||
String clientVersion = uriInfo.getQueryParameters().getFirst("client_configuration_version");
|
||||
LegacyConfiguration data = dataService.getConfiguration(
|
||||
appId, envId, configuration, clientId, clientVersion, accept);
|
||||
// A version stored without a content type would otherwise go out as the */* of @Produces.
|
||||
String contentType = data.contentType() != null ? data.contentType() : MediaType.APPLICATION_OCTET_STREAM;
|
||||
return Response.ok(data.content())
|
||||
.header("Content-Type", contentType)
|
||||
.header("Configuration-Version", data.configurationVersion())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
+52
-4
@@ -130,7 +130,9 @@ public class AppConfigDataService {
|
||||
byte[] content = new byte[0];
|
||||
String contentType = "application/octet-stream";
|
||||
if (version != null) {
|
||||
ResolvedContent resolved = resolveContent(session, version, accept);
|
||||
ConfigurationProfile profile = appConfigService.getConfigurationProfile(
|
||||
session.getApplicationId(), session.getConfigurationProfileId());
|
||||
ResolvedContent resolved = resolveContent(profile, version, accept);
|
||||
content = resolved.bytes();
|
||||
contentType = resolved.contentType();
|
||||
}
|
||||
@@ -140,10 +142,54 @@ public class AppConfigDataService {
|
||||
pollInterval);
|
||||
}
|
||||
|
||||
private ResolvedContent resolveContent(ConfigurationSession session, HostedConfigurationVersion version,
|
||||
public LegacyConfiguration getConfiguration(String application, String environment, String configuration,
|
||||
String clientId, String clientVersion, String accept) {
|
||||
for (String identifier : new String[]{application, environment, configuration, clientId}) {
|
||||
requireIdentifier(identifier, "Configuration identifier or client_id");
|
||||
if (identifier.length() > 64) {
|
||||
throw new AwsException("BadRequestException", "Identifiers must not exceed 64 characters", 400);
|
||||
}
|
||||
}
|
||||
if (clientVersion != null && (clientVersion.isEmpty() || clientVersion.length() > 1024)) {
|
||||
throw new AwsException("BadRequestException", "Invalid client_configuration_version", 400);
|
||||
}
|
||||
Application app = appConfigService.resolveApplication(application);
|
||||
Environment env;
|
||||
try {
|
||||
env = appConfigService.resolveEnvironment(app.getId(), environment);
|
||||
} catch (AwsException e) {
|
||||
if (!"ResourceNotFoundException".equals(e.getErrorCode())) {
|
||||
throw e;
|
||||
}
|
||||
// AWS answers a missing environment as it does an undeployed one; an unknown application or
|
||||
// profile stays ResourceNotFoundException.
|
||||
throw new AwsException("BadRequestException", e.getMessage(), 400);
|
||||
}
|
||||
ConfigurationProfile profile = appConfigService.resolveConfigurationProfile(app.getId(), configuration);
|
||||
String active = appConfigService.getActiveVersion(env.getId(), profile.getId());
|
||||
if (active == null) {
|
||||
throw new AwsException("BadRequestException", "No configuration is deployed", 400);
|
||||
}
|
||||
HostedConfigurationVersion version = appConfigService.getHostedConfigurationVersion(
|
||||
app.getId(), profile.getId(), hostedVersionNumber(active));
|
||||
if (active.equals(clientVersion)) {
|
||||
return new LegacyConfiguration(new byte[0], version.getContentType(), active);
|
||||
}
|
||||
ResolvedContent content = resolveContent(profile, version, accept);
|
||||
return new LegacyConfiguration(content.bytes(), content.contentType(), active);
|
||||
}
|
||||
|
||||
/** A deployed version that is not a version number names no hosted configuration version. */
|
||||
private static int hostedVersionNumber(String deployedVersion) {
|
||||
try {
|
||||
return Integer.parseInt(deployedVersion);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AwsException("ResourceNotFoundException", "Hosted configuration version not found", 404);
|
||||
}
|
||||
}
|
||||
|
||||
private ResolvedContent resolveContent(ConfigurationProfile profile, HostedConfigurationVersion version,
|
||||
String accept) {
|
||||
ConfigurationProfile profile = appConfigService.getConfigurationProfile(
|
||||
session.getApplicationId(), session.getConfigurationProfileId());
|
||||
if (!"AWS.AppConfig.FeatureFlags".equals(profile.getType())) {
|
||||
return new ResolvedContent(version.getContent(), version.getContentType());
|
||||
}
|
||||
@@ -251,6 +297,8 @@ public class AppConfigDataService {
|
||||
|
||||
private record ResolvedContent(byte[] bytes, String contentType) {}
|
||||
|
||||
public record LegacyConfiguration(byte[] content, String contentType, String configurationVersion) {}
|
||||
|
||||
public record ConfigurationData(byte[] content, String contentType, String configurationVersion,
|
||||
String nextPollConfigurationToken, int nextPollIntervalInSeconds) {}
|
||||
}
|
||||
+251
@@ -0,0 +1,251 @@
|
||||
package io.github.hectorvent.floci.services.appconfig;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
import io.restassured.response.Response;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@QuarkusTest
|
||||
class AppConfigLegacyIntegrationTest {
|
||||
private String application;
|
||||
private String environment;
|
||||
private String profile;
|
||||
private String strategy;
|
||||
private String name;
|
||||
|
||||
@BeforeEach
|
||||
void deployHostedConfiguration() {
|
||||
name = "legacy-" + UUID.randomUUID();
|
||||
application = given().contentType(ContentType.JSON).body(Map.of("Name", name))
|
||||
.post("/applications").then().statusCode(201).extract().path("Id");
|
||||
environment = createEnvironment("local");
|
||||
profile = createProfile(Map.of("Name", "settings", "LocationUri", "hosted"));
|
||||
createHostedVersion(profile, "{\"enabled\":true}");
|
||||
strategy = given().contentType(ContentType.JSON).body(Map.of(
|
||||
"Name", name, "DeploymentDurationInMinutes", 0, "GrowthFactor", 100,
|
||||
"FinalBakeTimeInMinutes", 0, "ReplicateTo", "NONE"))
|
||||
.post("/deploymentstrategies").then().statusCode(201).extract().path("Id");
|
||||
deploy(environment, profile, "1");
|
||||
}
|
||||
|
||||
private String createEnvironment(String environmentName) {
|
||||
return given().contentType(ContentType.JSON).body(Map.of("Name", environmentName))
|
||||
.post("/applications/" + application + "/environments")
|
||||
.then().statusCode(201).extract().path("Id");
|
||||
}
|
||||
|
||||
private String createProfile(Map<String, String> request) {
|
||||
return given().contentType(ContentType.JSON).body(request)
|
||||
.post("/applications/" + application + "/configurationprofiles")
|
||||
.then().statusCode(201).extract().path("Id");
|
||||
}
|
||||
|
||||
private void createHostedVersion(String profileId, String content) {
|
||||
createHostedVersion(profileId, content, ContentType.JSON.toString());
|
||||
}
|
||||
|
||||
private void createHostedVersion(String profileId, String content, String contentType) {
|
||||
given().contentType(contentType).body(content.getBytes(StandardCharsets.UTF_8))
|
||||
.post("/applications/" + application + "/configurationprofiles/" + profileId
|
||||
+ "/hostedconfigurationversions").then().statusCode(201);
|
||||
}
|
||||
|
||||
private void deploy(String environmentId, String profileId, String version) {
|
||||
given().contentType(ContentType.JSON).body(Map.of("ConfigurationProfileId", profileId,
|
||||
"ConfigurationVersion", version, "DeploymentStrategyId", strategy))
|
||||
.post("/applications/" + application + "/environments/" + environmentId + "/deployments")
|
||||
.then().statusCode(201);
|
||||
}
|
||||
|
||||
private String path() {
|
||||
return path(environment, profile);
|
||||
}
|
||||
|
||||
private String path(String environmentId, String profileId) {
|
||||
return "/applications/" + application + "/environments/" + environmentId + "/configurations/" + profileId;
|
||||
}
|
||||
|
||||
@Test
|
||||
void readsTheDeployedVersionByIdsAndNames() {
|
||||
for (String selected : new String[]{path(),
|
||||
"/applications/" + name + "/environments/local/configurations/settings"}) {
|
||||
given().queryParam("client_id", "reader").get(selected).then()
|
||||
.statusCode(200)
|
||||
.header("Configuration-Version", "1")
|
||||
.header("Content-Type", startsWith("application/json"))
|
||||
.body("enabled", equalTo(true));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void servesTheStoredContentTypeWhateverTheAcceptHeader() {
|
||||
String yaml = createProfile(Map.of("Name", "yaml-settings", "LocationUri", "hosted"));
|
||||
createHostedVersion(yaml, "enabled: true\n", "application/x-yaml");
|
||||
deploy(environment, yaml, "1");
|
||||
|
||||
given().accept("text/plain").queryParam("client_id", "reader").get(path(environment, yaml))
|
||||
.then().statusCode(200)
|
||||
.header("Content-Type", startsWith("application/x-yaml"))
|
||||
.body(equalTo("enabled: true\n"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aVersionStoredWithoutAContentTypeIsServedAsOctetStream() throws Exception {
|
||||
String untyped = createProfile(Map.of("Name", "untyped-settings", "LocationUri", "hosted"));
|
||||
// RestAssured stamps a default Content-Type on any request with a body, so this one uses a raw client.
|
||||
HttpResponse<String> created = HttpClient.newHttpClient().send(HttpRequest.newBuilder()
|
||||
.uri(URI.create("http://localhost:" + RestAssured.port + "/applications/" + application
|
||||
+ "/configurationprofiles/" + untyped + "/hostedconfigurationversions"))
|
||||
.POST(HttpRequest.BodyPublishers.ofString("raw"))
|
||||
.build(), HttpResponse.BodyHandlers.ofString());
|
||||
assertEquals(201, created.statusCode(), created.body());
|
||||
deploy(environment, untyped, "1");
|
||||
|
||||
given().queryParam("client_id", "reader").get(path(environment, untyped))
|
||||
.then().statusCode(200)
|
||||
.header("Content-Type", startsWith("application/octet-stream"))
|
||||
.body(equalTo("raw"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchingClientVersionReturnsAnEmptyBody() {
|
||||
given().queryParam("client_id", "reader").queryParam("client_configuration_version", "1")
|
||||
.get(path()).then().statusCode(200).header("Configuration-Version", "1").body(equalTo(""));
|
||||
given().queryParam("client_id", "reader").queryParam("client_configuration_version", "0")
|
||||
.get(path()).then().statusCode(200).body("enabled", equalTo(true));
|
||||
given().queryParam("client_id", "another-reader").get(path())
|
||||
.then().statusCode(200).body("enabled", equalTo(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUndeployedNewVersionDoesNotReplaceTheActiveVersion() {
|
||||
createHostedVersion(profile, "{\"enabled\":false}");
|
||||
given().queryParam("client_id", "reader").get(path())
|
||||
.then().statusCode(200).header("Configuration-Version", "1").body("enabled", equalTo(true));
|
||||
|
||||
deploy(environment, profile, "2");
|
||||
given().queryParam("client_id", "reader").queryParam("client_configuration_version", "1")
|
||||
.get(path()).then().statusCode(200).header("Configuration-Version", "2").body("enabled", equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void refusesMissingOrOversizedClientAndVersion() {
|
||||
given().get(path()).then().statusCode(400).body("__type", equalTo("BadRequestException"));
|
||||
given().queryParam("client_id", "").get(path()).then().statusCode(400);
|
||||
given().queryParam("client_id", "x".repeat(64)).get(path()).then().statusCode(200);
|
||||
given().queryParam("client_id", "x".repeat(65)).get(path()).then().statusCode(400);
|
||||
given().queryParam("client_id", "reader").queryParam("client_configuration_version", "")
|
||||
.get(path()).then().statusCode(400);
|
||||
given().queryParam("client_id", "reader").queryParam("client_configuration_version", "x".repeat(1024))
|
||||
.get(path()).then().statusCode(200);
|
||||
given().queryParam("client_id", "reader").queryParam("client_configuration_version", "x".repeat(1025))
|
||||
.get(path()).then().statusCode(400);
|
||||
given().queryParam("client_id", "reader").get(path(environment, "x".repeat(65)))
|
||||
.then().statusCode(400).body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void missingOrUndeployedEnvironmentIsABadRequest() {
|
||||
String undeployed = createEnvironment("staging");
|
||||
for (String selected : new String[]{path(undeployed, profile), path("absent", profile)}) {
|
||||
given().queryParam("client_id", "reader").get(selected)
|
||||
.then().statusCode(400).body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownApplicationOrProfileIsNotFound() {
|
||||
String deletedApplication = given().contentType(ContentType.JSON).body(Map.of("Name", "gone-" + UUID.randomUUID()))
|
||||
.post("/applications").then().statusCode(201).extract().path("Id");
|
||||
given().delete("/applications/" + deletedApplication).then().statusCode(204);
|
||||
String otherApplication = given().contentType(ContentType.JSON).body(Map.of("Name", "other-" + UUID.randomUUID()))
|
||||
.post("/applications").then().statusCode(201).extract().path("Id");
|
||||
String otherProfile = given().contentType(ContentType.JSON)
|
||||
.body(Map.of("Name", "other-settings", "LocationUri", "hosted"))
|
||||
.post("/applications/" + otherApplication + "/configurationprofiles")
|
||||
.then().statusCode(201).extract().path("Id");
|
||||
|
||||
Map<String, String> selected = new LinkedHashMap<>();
|
||||
selected.put("application by name",
|
||||
"/applications/absent-" + UUID.randomUUID() + "/environments/local/configurations/settings");
|
||||
selected.put("application by id",
|
||||
"/applications/" + deletedApplication + "/environments/local/configurations/settings");
|
||||
selected.put("profile by name", path(environment, "absent-settings"));
|
||||
selected.put("profile by id", path(environment, otherProfile));
|
||||
Map<String, String> expected = new LinkedHashMap<>();
|
||||
Map<String, String> actual = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, String> entry : selected.entrySet()) {
|
||||
Response response = given().queryParam("client_id", "reader").get(entry.getValue());
|
||||
expected.put(entry.getKey(), "404 ResourceNotFoundException");
|
||||
actual.put(entry.getKey(), response.statusCode() + " " + response.path("__type"));
|
||||
}
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deployedVersionWithoutHostedContentIsNotFound() {
|
||||
String s3Profile = createProfile(Map.of("Name", "s3-settings", "LocationUri", "s3://bucket/settings.json"));
|
||||
deploy(environment, s3Profile, "3sL4kqtJlcpXroDTDmJ");
|
||||
given().queryParam("client_id", "reader").get(path(environment, s3Profile))
|
||||
.then().statusCode(404).body("__type", equalTo("ResourceNotFoundException"));
|
||||
|
||||
given().delete("/applications/" + application + "/configurationprofiles/" + profile
|
||||
+ "/hostedconfigurationversions/1").then().statusCode(204);
|
||||
given().queryParam("client_id", "reader").get(path())
|
||||
.then().statusCode(404).body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void featureFlagsAreReturnedInRetrievalFormat() {
|
||||
String flags = createProfile(Map.of("Name", "flags", "LocationUri", "hosted",
|
||||
"Type", "AWS.AppConfig.FeatureFlags"));
|
||||
createHostedVersion(flags, "{\"flags\":{\"beta\":{\"name\":\"beta\"}},"
|
||||
+ "\"values\":{\"beta\":{\"enabled\":true,\"_createdAt\":\"created\"}},\"version\":\"1\"}");
|
||||
deploy(environment, flags, "1");
|
||||
|
||||
given().queryParam("client_id", "reader").get(path(environment, flags))
|
||||
.then().statusCode(200)
|
||||
.header("Configuration-Version", "1")
|
||||
.body("beta.enabled", equalTo(true))
|
||||
.body("beta._createdAt", nullValue())
|
||||
.body("values", nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void variantFeatureFlagsAreIonForACallerThatAcceptsOnlyIon() {
|
||||
String flags = createProfile(Map.of("Name", "variant-flags", "LocationUri", "hosted",
|
||||
"Type", "AWS.AppConfig.FeatureFlags"));
|
||||
createHostedVersion(flags, "{\"flags\":{},\"version\":\"1\",\"values\":{\"promo\":{\"_variants\":["
|
||||
+ "{\"attributeValues\":{\"storeId\":\"uk\"},\"enabled\":true,\"name\":\"uk\","
|
||||
+ "\"rule\":\"(eq $storeId \\\"uk\\\")\"},{\"enabled\":false,\"name\":\"default\"}]}}}");
|
||||
deploy(environment, flags, "1");
|
||||
|
||||
byte[] ion = given().accept("application/ion; type=AWS.AppConfig.FeatureFlags")
|
||||
.queryParam("client_id", "reader").get(path(environment, flags))
|
||||
.then().statusCode(200)
|
||||
.header("Configuration-Version", "1")
|
||||
.header("Content-Type", startsWith("application/ion"))
|
||||
.extract().asByteArray();
|
||||
assertEquals(IonTestSupport.parse("promo::[uk::[(eq $storeId \"uk\"), "
|
||||
+ "'''{\"_variant\":\"uk\",\"enabled\":true,\"storeId\":\"uk\"}'''],"
|
||||
+ "'''{\"_variant\":\"default\",\"enabled\":false}''']"),
|
||||
IonTestSupport.decode(ion));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user