Skip to content

Commit

Permalink
V1.14.1 (#219)
Browse files Browse the repository at this point in the history
* Update Console to 3.5.0

* #220 - OCR Processor fails to create with using a long appenvironment name #220
  • Loading branch information
mfriesen committed Apr 23, 2024
1 parent d938221 commit d5d1ac7
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def getCmdParam() {
repositories { mavenCentral() }

allprojects {
version = '1.14.0'
version = '1.14.1'
ext.awsCognitoVersion = '1.5.3'
group = 'com.formkiq.stacks'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void testS3Buckets() {
*/
@Test
public void testSsmParameters() {
assertEquals("v3.4.0",
assertEquals("v3.5.0",
ssmService.getParameterValue("/formkiq/" + appenvironment + "/console/version"));
assertTrue(ssmService.getParameterValue("/formkiq/" + appenvironment + "/s3/Console")
.contains(appenvironment + "-console-"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,19 @@ private void createCognitoConfig(final LambdaLogger logger) {
String congitoClientId = this.environmentMap.get("COGNITO_USER_POOL_CLIENT_ID");

String documentApi = this.environmentMap.get("API_URL");
String cognitoSingleSignOnUrl = this.environmentMap.get("COGNITO_SINGLE_SIGN_ON_URL");
if (cognitoSingleSignOnUrl == null) {
cognitoSingleSignOnUrl = "";
}

String json = String.format(
"{%n" + " \"documentApi\": \"%s\",%n" + " \"userPoolId\": \"%s\",%n"
+ " \"clientId\": \"%s\",%n" + " \"consoleVersion\": \"%s\",%n"
+ " \"brand\": \"%s\",%n" + " \"userAuthentication\": \"%s\",%n"
+ " \"authApi\": \"%s\",%n" + " \"cognitoHostedUi\": \"%s\"%n" + "}",
+ " \"authApi\": \"%s\",%n" + " \"cognitoHostedUi\": \"%s\",%n"
+ " \"cognitoSingleSignOnUrl\": \"%s\"%n" + "}",
documentApi, cognitoUserPoolId, congitoClientId, consoleVersion, brand, userAuthentication,
authApi, cognitoHostedUi);
authApi, cognitoHostedUi, cognitoSingleSignOnUrl);

String fileName = consoleVersion + "/assets/config.json";

Expand Down
2 changes: 1 addition & 1 deletion console/src/main/resources/cloudformation/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Parameters:
ConsoleVersion:
Type: String
Description: Version of FormKiQ console to deploy
Default: v3.4.0
Default: v3.5.0

FormKiQType:
Description: The type of FormKiQ installation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ public static void beforeClass() throws IOException, URISyntaxException, Interru
/** before. */
@BeforeEach
public void before() {
Map<String, String> map = createEnvironment();
createHandler(map);
}

private Map<String, String> createEnvironment() {
Map<String, String> map = new HashMap<>();
map.put("CONSOLE_VERSION", "0.1");
map.put("REGION", "us-east-1");
Expand All @@ -132,7 +136,10 @@ public void before() {
map.put("DOMAIN", "dev");
map.put("COGNITO_USER_POOL_ID", "us-east-2_blGeBpyLg");
map.put("COGNITO_USER_POOL_CLIENT_ID", "7223423m2pfgf34qnfokb2po2l");
return map;
}

private void createHandler(final Map<String, String> map) {
this.handler = new ConsoleInstallHandler(map, s3Connection, s3Connection) {

@Override
Expand Down Expand Up @@ -185,19 +192,16 @@ public void testHandleRequest01() throws Exception {
this.logger.log("sending SUCCESS to https://cloudformation-custom-resource");
this.logger.log("Request Create was successful!");


// replayAll();
this.handler.handleRequest(input, this.context);

// then
verifySendResponse(contentlength);
verifyConfigWritten();
verifyConfigWritten("");
verifyCognitoConfig();

assertTrue(connection.contains("\"Status\":\"SUCCESS\""));
assertTrue(connection.contains("\"Data\":{\"Message\":\"Request Create was successful!\""));


assertEquals("font/woff2",
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/font.woff2", null).getContentType());

Expand Down Expand Up @@ -252,7 +256,7 @@ public void testHandleRequest02() throws Exception {

// then
verifySendResponse(contentlength);
verifyConfigWritten();
verifyConfigWritten("");
verifyCognitoConfig();

assertTrue(this.logger.containsString(
Expand Down Expand Up @@ -360,18 +364,95 @@ public void testHandleRequest04() throws Exception {
assertTrue(connection.contains("\"Status\":\"FAILURE\""));
}

/**
* Test Handle Request 'CREATE'.
*
* @throws Exception Exception
*/
@Test
public void testHandleRequest05() throws Exception {
// given
String cognitoSingleSignOnUrl =
"https://something.auth.us-east-2.amazoncognito.com/oauth2/authorize";
Map<String, String> map = createEnvironment();
map.put("COGNITO_SINGLE_SIGN_ON_URL", cognitoSingleSignOnUrl);
createHandler(map);

final int contentlength = 105;
Map<String, Object> input = createInput("Create");
input.put("CONSOLE_BUCKET", CONSOLE_BUCKET);

// when
this.logger.log(
"received input: {ResponseURL=https://cloudformation-custom-resource, RequestType=Create}");
this.logger.log("unpacking formkiq-console/0.1/formkiq-console.zip "
+ "from bucket distrobucket to bucket destbucket");
this.logger.log("sending SUCCESS to https://cloudformation-custom-resource");
this.logger.log("Request Create was successful!");

this.handler.handleRequest(input, this.context);

// then
verifySendResponse(contentlength);
verifyConfigWritten(cognitoSingleSignOnUrl);
verifyCognitoConfig();

assertTrue(connection.contains("\"Status\":\"SUCCESS\""));
assertTrue(connection.contains("\"Data\":{\"Message\":\"Request Create was successful!\""));

assertEquals("font/woff2",
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/font.woff2", null).getContentType());

assertEquals("text/css",
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.css", null).getContentType());

assertEquals("application/vnd.ms-fontobject",
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.eot", null).getContentType());

assertEquals("image/x-icon",
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.ico", null).getContentType());

assertTrue(s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.js", null).getContentType()
.endsWith("/javascript"));

assertEquals("image/svg+xml",
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.svg", null).getContentType());

assertEquals("font/ttf",
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.ttf", null).getContentType());

assertEquals("text/plain",
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.txt", null).getContentType());

assertEquals("font/woff",
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.woff", null).getContentType());

// given
input = createInput("Delete");
input.put("CONSOLE_BUCKET", CONSOLE_BUCKET);

// when
this.handler.handleRequest(input, this.context);

// then
assertTrue(s3.listObjects(CONSOLE_BUCKET, null).contents().isEmpty());
}

/**
* Verify Config File is written.
*
* @param cognitoSingleSignOnUrl {@link String}
*/
private void verifyConfigWritten() {
private void verifyConfigWritten(final String cognitoSingleSignOnUrl) {

String config = String.format("{%n"
+ " \"documentApi\": \"https://chartapi.24hourcharts.com.execute-api.us-east-1.amazonaws.com/prod/\",%n"
+ " \"userPoolId\": \"us-east-2_blGeBpyLg\",%n"
+ " \"clientId\": \"7223423m2pfgf34qnfokb2po2l\",%n" + " \"consoleVersion\": \"0.1\",%n"
+ " \"brand\": \"24hourcharts\",%n" + " \"userAuthentication\": \"cognito\",%n"
+ " \"authApi\": \"https://auth.execute-api.us-east-1.amazonaws.com/prod/\",%n"
+ " \"cognitoHostedUi\": \"https://test2111111111111111.auth.us-east-2.amazoncognito.com\"%n"
+ "}");
+ " \"cognitoHostedUi\": \"https://test2111111111111111.auth.us-east-2.amazoncognito.com\",%n"
+ " \"cognitoSingleSignOnUrl\": \"" + cognitoSingleSignOnUrl + "\"%n" + "}");

assertTrue(this.logger.containsString("writing Cognito config: " + config));
}
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi/openapi-iam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- OAuth(JWT)
- AWS IAM
- API Key
version: 1.14.0
version: 1.14.1
tags:
- name: documents
description: API for the add, updating and fetching of documents
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi/openapi-jwt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- OAuth(JWT)
- AWS IAM
- API Key
version: 1.14.0
version: 1.14.1
tags:
- name: documents
description: API for the add, updating and fetching of documents
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi/openapi-key.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- OAuth(JWT)
- AWS IAM
- API Key
version: 1.14.0
version: 1.14.1
tags:
- name: documents
description: API for the add, updating and fetching of documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ Resources:
Type: AWS::Serverless::LayerVersion
Properties:
Description: Lambda Layer containing Tesseract binary
LayerName:
Fn::Sub: "${AWS::StackName}-${AppEnvironment}-tesseract-layer"
ContentUri: ./layer-tesseract-5.3.1.zip

OcrProcessorApiInvokePermission:
Expand Down

0 comments on commit d5d1ac7

Please sign in to comment.