diff --git a/infrastructure/test/hostedzone-stack.test.ts b/infrastructure/test/hostedzone-stack.test.ts index cf114d7..9580d19 100644 --- a/infrastructure/test/hostedzone-stack.test.ts +++ b/infrastructure/test/hostedzone-stack.test.ts @@ -10,6 +10,26 @@ test('HostedZone Stack Test', () => { hostedZone: Project.METRICS_HOSTED_ZONE, appName: "OpenSearchMetrics" }); + const hostedZoneCognitoStack = new OpenSearchHealthRoute53(app, 'Test-OpenSearchMetrics-HostedZoneCognito', { + hostedZone: Project.METRICS_COGNITO_HOSTED_ZONE, + appName: "OpenSearchMetricsCognito" + }); const hostedZoneStackTemplate = Template.fromStack(hostedZoneStack); + hostedZoneStackTemplate.resourceCountIs('AWS::Route53::HostedZone', 1); + hostedZoneStackTemplate.hasResourceProperties('AWS::Route53::HostedZone', { + "Name": "metrics.opensearch.org." + }); + hostedZoneStackTemplate.hasResourceProperties('AWS::CertificateManager::Certificate', { + "DomainName": "metrics.opensearch.org" + }); + + const hostedZoneCognitoStackTemplate = Template.fromStack(hostedZoneCognitoStack); + hostedZoneCognitoStackTemplate.resourceCountIs('AWS::Route53::HostedZone', 1); + hostedZoneCognitoStackTemplate.hasResourceProperties('AWS::Route53::HostedZone', { + "Name": "metrics.login.opensearch.org." + }); + hostedZoneCognitoStackTemplate.hasResourceProperties('AWS::CertificateManager::Certificate', { + "DomainName": "metrics.login.opensearch.org" + }); }); \ No newline at end of file diff --git a/infrastructure/test/nginx-proxy-readonly.test.ts b/infrastructure/test/nginx-proxy-readonly.test.ts new file mode 100644 index 0000000..0e4c0ca --- /dev/null +++ b/infrastructure/test/nginx-proxy-readonly.test.ts @@ -0,0 +1,48 @@ +import {App} from "aws-cdk-lib"; +import {Template} from "aws-cdk-lib/assertions"; +import Project from "../lib/enums/project"; +import {OpenSearchMetricsNginxReadonly} from "../lib/stacks/opensearchNginxProxyReadonly"; +import {VpcStack} from "../lib/stacks/vpc"; +import {OpenSearchDomainStack} from "../lib/stacks/opensearch"; +import {ArnPrincipal} from "aws-cdk-lib/aws-iam"; +import {OpenSearchHealthRoute53} from "../lib/stacks/route53"; + +test('NginxProxyReadonly Stack Test', () => { + const app = new App(); + const vpcStack = new VpcStack(app, 'Test-OpenSearchHealth-VPC', {}); + const openSearchDomainStack = new OpenSearchDomainStack(app, 'Test-OpenSearchHealth-OpenSearch', { + region: "us-east-1", + account: "test-account", + vpcStack: vpcStack, + enableNginxCognito: true, + jenkinsAccess: { + jenkinsAccountRoles: [ + new ArnPrincipal(Project.JENKINS_MASTER_ROLE), + new ArnPrincipal(Project.JENKINS_AGENT_ROLE) + ] + } + }); + const metricsHostedZone = new OpenSearchHealthRoute53(app, 'Test-OpenSearchMetrics-HostedZone', { + hostedZone: Project.METRICS_HOSTED_ZONE, + appName: "OpenSearchMetrics" + }); + const openSearchMetricsNginxReadonlyStack = new OpenSearchMetricsNginxReadonly(app, 'Test-OpenSearchMetricsNginxReadonly', { + region: Project.REGION, + account: Project.AWS_ACCOUNT, + vpc: vpcStack.vpc, + securityGroup: vpcStack.securityGroup, + opensearchDashboardUrlProps: { + opensearchDashboardVpcUrl: openSearchDomainStack.domain.domainEndpoint, + openSearchDomainName: openSearchDomainStack.domain.domainName + }, + albProps: { + hostedZone: metricsHostedZone, + certificateArn: metricsHostedZone.certificateArn, + }, + }); + const openSearchMetricsNginxReadonlyTemplate = Template.fromStack(openSearchMetricsNginxReadonlyStack); + openSearchMetricsNginxReadonlyTemplate.resourceCountIs('AWS::Route53::RecordSet', 1); + openSearchMetricsNginxReadonlyTemplate.hasResourceProperties('AWS::Route53::RecordSet', { + "Type": "A" + }); +}); \ No newline at end of file