Skip to content

Commit d5d1ac7

Browse files
authored
V1.14.1 (#219)
* Update Console to 3.5.0 * #220 - OCR Processor fails to create with using a long appenvironment name #220
1 parent d938221 commit d5d1ac7

File tree

9 files changed

+102
-18
lines changed

9 files changed

+102
-18
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def getCmdParam() {
2626
repositories { mavenCentral() }
2727

2828
allprojects {
29-
version = '1.14.0'
29+
version = '1.14.1'
3030
ext.awsCognitoVersion = '1.5.3'
3131
group = 'com.formkiq.stacks'
3232

console/src/integration/java/com/formkiq/stacks/console/awstest/AwsResourceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public void testS3Buckets() {
201201
*/
202202
@Test
203203
public void testSsmParameters() {
204-
assertEquals("v3.4.0",
204+
assertEquals("v3.5.0",
205205
ssmService.getParameterValue("/formkiq/" + appenvironment + "/console/version"));
206206
assertTrue(ssmService.getParameterValue("/formkiq/" + appenvironment + "/s3/Console")
207207
.contains(appenvironment + "-console-"));

console/src/main/java/com/formkiq/stacks/console/ConsoleInstallHandler.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,19 @@ private void createCognitoConfig(final LambdaLogger logger) {
108108
String congitoClientId = this.environmentMap.get("COGNITO_USER_POOL_CLIENT_ID");
109109

110110
String documentApi = this.environmentMap.get("API_URL");
111+
String cognitoSingleSignOnUrl = this.environmentMap.get("COGNITO_SINGLE_SIGN_ON_URL");
112+
if (cognitoSingleSignOnUrl == null) {
113+
cognitoSingleSignOnUrl = "";
114+
}
111115

112116
String json = String.format(
113117
"{%n" + " \"documentApi\": \"%s\",%n" + " \"userPoolId\": \"%s\",%n"
114118
+ " \"clientId\": \"%s\",%n" + " \"consoleVersion\": \"%s\",%n"
115119
+ " \"brand\": \"%s\",%n" + " \"userAuthentication\": \"%s\",%n"
116-
+ " \"authApi\": \"%s\",%n" + " \"cognitoHostedUi\": \"%s\"%n" + "}",
120+
+ " \"authApi\": \"%s\",%n" + " \"cognitoHostedUi\": \"%s\",%n"
121+
+ " \"cognitoSingleSignOnUrl\": \"%s\"%n" + "}",
117122
documentApi, cognitoUserPoolId, congitoClientId, consoleVersion, brand, userAuthentication,
118-
authApi, cognitoHostedUi);
123+
authApi, cognitoHostedUi, cognitoSingleSignOnUrl);
119124

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

console/src/main/resources/cloudformation/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Parameters:
1717
ConsoleVersion:
1818
Type: String
1919
Description: Version of FormKiQ console to deploy
20-
Default: v3.4.0
20+
Default: v3.5.0
2121

2222
FormKiQType:
2323
Description: The type of FormKiQ installation

console/src/test/java/com/formkiq/stacks/console/ConsoleInstallHandlerTest.java

Lines changed: 89 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ public static void beforeClass() throws IOException, URISyntaxException, Interru
114114
/** before. */
115115
@BeforeEach
116116
public void before() {
117+
Map<String, String> map = createEnvironment();
118+
createHandler(map);
119+
}
117120

121+
private Map<String, String> createEnvironment() {
118122
Map<String, String> map = new HashMap<>();
119123
map.put("CONSOLE_VERSION", "0.1");
120124
map.put("REGION", "us-east-1");
@@ -132,7 +136,10 @@ public void before() {
132136
map.put("DOMAIN", "dev");
133137
map.put("COGNITO_USER_POOL_ID", "us-east-2_blGeBpyLg");
134138
map.put("COGNITO_USER_POOL_CLIENT_ID", "7223423m2pfgf34qnfokb2po2l");
139+
return map;
140+
}
135141

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

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

188-
189-
// replayAll();
190195
this.handler.handleRequest(input, this.context);
191196

192197
// then
193198
verifySendResponse(contentlength);
194-
verifyConfigWritten();
199+
verifyConfigWritten("");
195200
verifyCognitoConfig();
196201

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

200-
201205
assertEquals("font/woff2",
202206
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/font.woff2", null).getContentType());
203207

@@ -252,7 +256,7 @@ public void testHandleRequest02() throws Exception {
252256

253257
// then
254258
verifySendResponse(contentlength);
255-
verifyConfigWritten();
259+
verifyConfigWritten("");
256260
verifyCognitoConfig();
257261

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

367+
/**
368+
* Test Handle Request 'CREATE'.
369+
*
370+
* @throws Exception Exception
371+
*/
372+
@Test
373+
public void testHandleRequest05() throws Exception {
374+
// given
375+
String cognitoSingleSignOnUrl =
376+
"https://something.auth.us-east-2.amazoncognito.com/oauth2/authorize";
377+
Map<String, String> map = createEnvironment();
378+
map.put("COGNITO_SINGLE_SIGN_ON_URL", cognitoSingleSignOnUrl);
379+
createHandler(map);
380+
381+
final int contentlength = 105;
382+
Map<String, Object> input = createInput("Create");
383+
input.put("CONSOLE_BUCKET", CONSOLE_BUCKET);
384+
385+
// when
386+
this.logger.log(
387+
"received input: {ResponseURL=https://cloudformation-custom-resource, RequestType=Create}");
388+
this.logger.log("unpacking formkiq-console/0.1/formkiq-console.zip "
389+
+ "from bucket distrobucket to bucket destbucket");
390+
this.logger.log("sending SUCCESS to https://cloudformation-custom-resource");
391+
this.logger.log("Request Create was successful!");
392+
393+
this.handler.handleRequest(input, this.context);
394+
395+
// then
396+
verifySendResponse(contentlength);
397+
verifyConfigWritten(cognitoSingleSignOnUrl);
398+
verifyCognitoConfig();
399+
400+
assertTrue(connection.contains("\"Status\":\"SUCCESS\""));
401+
assertTrue(connection.contains("\"Data\":{\"Message\":\"Request Create was successful!\""));
402+
403+
assertEquals("font/woff2",
404+
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/font.woff2", null).getContentType());
405+
406+
assertEquals("text/css",
407+
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.css", null).getContentType());
408+
409+
assertEquals("application/vnd.ms-fontobject",
410+
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.eot", null).getContentType());
411+
412+
assertEquals("image/x-icon",
413+
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.ico", null).getContentType());
414+
415+
assertTrue(s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.js", null).getContentType()
416+
.endsWith("/javascript"));
417+
418+
assertEquals("image/svg+xml",
419+
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.svg", null).getContentType());
420+
421+
assertEquals("font/ttf",
422+
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.ttf", null).getContentType());
423+
424+
assertEquals("text/plain",
425+
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.txt", null).getContentType());
426+
427+
assertEquals("font/woff",
428+
s3.getObjectMetadata(CONSOLE_BUCKET, "0.1/test.woff", null).getContentType());
429+
430+
// given
431+
input = createInput("Delete");
432+
input.put("CONSOLE_BUCKET", CONSOLE_BUCKET);
433+
434+
// when
435+
this.handler.handleRequest(input, this.context);
436+
437+
// then
438+
assertTrue(s3.listObjects(CONSOLE_BUCKET, null).contents().isEmpty());
439+
}
440+
363441
/**
364442
* Verify Config File is written.
443+
*
444+
* @param cognitoSingleSignOnUrl {@link String}
365445
*/
366-
private void verifyConfigWritten() {
446+
private void verifyConfigWritten(final String cognitoSingleSignOnUrl) {
447+
367448
String config = String.format("{%n"
368449
+ " \"documentApi\": \"https://chartapi.24hourcharts.com.execute-api.us-east-1.amazonaws.com/prod/\",%n"
369450
+ " \"userPoolId\": \"us-east-2_blGeBpyLg\",%n"
370451
+ " \"clientId\": \"7223423m2pfgf34qnfokb2po2l\",%n" + " \"consoleVersion\": \"0.1\",%n"
371452
+ " \"brand\": \"24hourcharts\",%n" + " \"userAuthentication\": \"cognito\",%n"
372453
+ " \"authApi\": \"https://auth.execute-api.us-east-1.amazonaws.com/prod/\",%n"
373-
+ " \"cognitoHostedUi\": \"https://test2111111111111111.auth.us-east-2.amazoncognito.com\"%n"
374-
+ "}");
454+
+ " \"cognitoHostedUi\": \"https://test2111111111111111.auth.us-east-2.amazoncognito.com\",%n"
455+
+ " \"cognitoSingleSignOnUrl\": \"" + cognitoSingleSignOnUrl + "\"%n" + "}");
375456

376457
assertTrue(this.logger.containsString("writing Cognito config: " + config));
377458
}

docs/openapi/openapi-iam.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
- OAuth(JWT)
3333
- AWS IAM
3434
- API Key
35-
version: 1.14.0
35+
version: 1.14.1
3636
tags:
3737
- name: documents
3838
description: API for the add, updating and fetching of documents

docs/openapi/openapi-jwt.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
- OAuth(JWT)
3333
- AWS IAM
3434
- API Key
35-
version: 1.14.0
35+
version: 1.14.1
3636
tags:
3737
- name: documents
3838
description: API for the add, updating and fetching of documents

docs/openapi/openapi-key.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
- OAuth(JWT)
3333
- AWS IAM
3434
- API Key
35-
version: 1.14.0
35+
version: 1.14.1
3636
tags:
3737
- name: documents
3838
description: API for the add, updating and fetching of documents

lambda-ocr-tesseract/src/main/resources/cloudformation/template-ocr.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ Resources:
4747
Type: AWS::Serverless::LayerVersion
4848
Properties:
4949
Description: Lambda Layer containing Tesseract binary
50-
LayerName:
51-
Fn::Sub: "${AWS::StackName}-${AppEnvironment}-tesseract-layer"
5250
ContentUri: ./layer-tesseract-5.3.1.zip
5351

5452
OcrProcessorApiInvokePermission:

0 commit comments

Comments
 (0)