@webda/aws 2.0.0-beta.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/lib/deployers/cloudformation.d.ts +3 -3
  2. package/lib/deployers/cloudformation.js +673 -694
  3. package/lib/deployers/cloudformation.js.map +1 -1
  4. package/lib/deployers/cloudformation.spec.js +428 -477
  5. package/lib/deployers/cloudformation.spec.js.map +1 -1
  6. package/lib/deployers/index.js +282 -342
  7. package/lib/deployers/index.js.map +1 -1
  8. package/lib/deployers/index.spec.d.ts +1 -1
  9. package/lib/deployers/index.spec.js +445 -510
  10. package/lib/deployers/index.spec.js.map +1 -1
  11. package/lib/deployers/lambda-entrypoint.js +4 -16
  12. package/lib/deployers/lambda-entrypoint.js.map +1 -1
  13. package/lib/deployers/lambdapackager.d.ts +1 -1
  14. package/lib/deployers/lambdapackager.js +14 -53
  15. package/lib/deployers/lambdapackager.js.map +1 -1
  16. package/lib/deployers/lambdapackager.spec.js +25 -61
  17. package/lib/deployers/lambdapackager.spec.js.map +1 -1
  18. package/lib/index.d.ts +1 -1
  19. package/lib/index.js +1 -17
  20. package/lib/index.js.map +1 -1
  21. package/lib/index.spec.d.ts +1 -1
  22. package/lib/index.spec.js +28 -75
  23. package/lib/index.spec.js.map +1 -1
  24. package/lib/services/aws-mixin.d.ts +2 -0
  25. package/lib/services/aws-mixin.js +2 -7
  26. package/lib/services/aws-mixin.js.map +1 -1
  27. package/lib/services/cloudwatchlogger.d.ts +3 -1
  28. package/lib/services/cloudwatchlogger.js +63 -104
  29. package/lib/services/cloudwatchlogger.js.map +1 -1
  30. package/lib/services/cloudwatchlogger.spec.js +57 -100
  31. package/lib/services/cloudwatchlogger.spec.js.map +1 -1
  32. package/lib/services/dynamodb.d.ts +4 -2
  33. package/lib/services/dynamodb.js +457 -498
  34. package/lib/services/dynamodb.js.map +1 -1
  35. package/lib/services/dynamodb.spec.d.ts +2 -2
  36. package/lib/services/dynamodb.spec.js +231 -302
  37. package/lib/services/dynamodb.spec.js.map +1 -1
  38. package/lib/services/index.d.ts +9 -9
  39. package/lib/services/index.js +8 -24
  40. package/lib/services/index.js.map +1 -1
  41. package/lib/services/lambdacaller.d.ts +2 -0
  42. package/lib/services/lambdacaller.js +15 -29
  43. package/lib/services/lambdacaller.js.map +1 -1
  44. package/lib/services/lambdacaller.spec.js +43 -81
  45. package/lib/services/lambdacaller.spec.js.map +1 -1
  46. package/lib/services/lambdaserver.js +167 -190
  47. package/lib/services/lambdaserver.js.map +1 -1
  48. package/lib/services/lambdaserver.spec.js +266 -354
  49. package/lib/services/lambdaserver.spec.js.map +1 -1
  50. package/lib/services/route53.js +112 -137
  51. package/lib/services/route53.js.map +1 -1
  52. package/lib/services/route53.spec.js +56 -92
  53. package/lib/services/route53.spec.js.map +1 -1
  54. package/lib/services/s3binary.d.ts +6 -2
  55. package/lib/services/s3binary.js +189 -251
  56. package/lib/services/s3binary.js.map +1 -1
  57. package/lib/services/s3binary.spec.js +185 -254
  58. package/lib/services/s3binary.spec.js.map +1 -1
  59. package/lib/services/secretsmanager.d.ts +2 -0
  60. package/lib/services/secretsmanager.js +32 -56
  61. package/lib/services/secretsmanager.js.map +1 -1
  62. package/lib/services/secretsmanager.spec.js +50 -93
  63. package/lib/services/secretsmanager.spec.js.map +1 -1
  64. package/lib/services/sqsqueue.d.ts +5 -7
  65. package/lib/services/sqsqueue.js +70 -99
  66. package/lib/services/sqsqueue.js.map +1 -1
  67. package/lib/services/sqsqueue.spec.js +95 -145
  68. package/lib/services/sqsqueue.spec.js.map +1 -1
  69. package/lib/shell.js +19 -38
  70. package/lib/shell.js.map +1 -1
  71. package/package.json +12 -9
  72. package/webda.module.json +54 -6
@@ -1,547 +1,498 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
6
  };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
32
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
33
- return new (P || (P = Promise))(function (resolve, reject) {
34
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
35
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
36
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
37
- step((generator = generator.apply(thisArg, _arguments || [])).next());
38
- });
39
- };
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- const client_api_gateway_1 = require("@aws-sdk/client-api-gateway");
42
- const client_cloudformation_1 = require("@aws-sdk/client-cloudformation");
43
- const client_sts_1 = require("@aws-sdk/client-sts");
44
- const mocha_1 = require("@testdeck/mocha");
45
- const core_1 = require("@webda/core");
46
- const deployertest_1 = require("@webda/shell/lib/deployers/deployertest");
47
- const assert = __importStar(require("assert"));
48
- const aws_sdk_client_mock_1 = require("aws-sdk-client-mock");
49
- const sinon = __importStar(require("sinon"));
50
- const index_spec_1 = require("../index.spec");
51
- const cloudformation_1 = require("./cloudformation");
52
- const index_spec_2 = require("./index.spec");
53
- let CloudFormationDeployerTest = class CloudFormationDeployerTest extends deployertest_1.DeployerTest {
7
+ import { APIGateway, CreateDeploymentCommand, PutRestApiCommand } from "@aws-sdk/client-api-gateway";
8
+ import { CloudFormation, CreateChangeSetCommand, CreateStackCommand, DeleteChangeSetCommand, DeleteStackCommand, DescribeChangeSetCommand, DescribeStackEventsCommand, DescribeStacksCommand, ExecuteChangeSetCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
9
+ import { GetCallerIdentityCommand, STS } from "@aws-sdk/client-sts";
10
+ import { suite, test } from "@testdeck/mocha";
11
+ import { JSONUtils } from "@webda/core";
12
+ import { DeployerTest } from "@webda/shell/lib/deployers/deployertest.js";
13
+ import * as assert from "assert";
14
+ import { mockClient } from "aws-sdk-client-mock";
15
+ import * as sinon from "sinon";
16
+ import { defaultCreds } from "../index.spec.js";
17
+ import { CloudFormationDeployer, LAMBDA_LATEST_VERSION } from "./cloudformation.js";
18
+ import { MockAWSDeployerMethods } from "./index.spec.js";
19
+ let CloudFormationDeployerTest = class CloudFormationDeployerTest extends DeployerTest {
54
20
  constructor() {
55
21
  super(...arguments);
56
22
  this.mocks = {};
57
23
  }
58
- getDeployer(manager) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- let deployer = yield manager.getDeployer("WebdaSampleApplication");
61
- (0, index_spec_2.MockAWSDeployerMethods)(deployer, this);
62
- return deployer;
24
+ async getDeployer(manager) {
25
+ let deployer = await manager.getDeployer("WebdaSampleApplication");
26
+ MockAWSDeployerMethods(deployer, this);
27
+ return deployer;
28
+ }
29
+ async defaultResources() {
30
+ let resources = this.deployer.resources;
31
+ resources.Lambda = {};
32
+ resources.APIGateway = {};
33
+ resources.APIGatewayDomain = { DomainName: "webda.io" };
34
+ resources.Policy = {};
35
+ resources.APIGatewayBasePathMapping = {};
36
+ resources = JSONUtils.duplicate(resources);
37
+ await this.deployer.defaultResources();
38
+ assert.deepStrictEqual(this.deployer.resources.APIGatewayBasePathMapping, {
39
+ ...resources.APIGatewayDomain,
40
+ BasePath: ""
41
+ });
42
+ assert.deepStrictEqual(this.deployer.resources.APIGatewayDomain, {
43
+ ...resources.APIGatewayDomain,
44
+ SecurityPolicy: "TLS_1_2"
63
45
  });
46
+ assert.deepStrictEqual(this.deployer.resources.Lambda, {
47
+ ...resources.Lambda,
48
+ FunctionName: "WebdaSampleApplication",
49
+ Handler: "node_modules/@webda/aws/lib/deployers/lambda-entrypoint.handler",
50
+ MemorySize: 2048,
51
+ Role: { "Fn::GetAtt": ["Role", "Arn"] },
52
+ Runtime: LAMBDA_LATEST_VERSION,
53
+ Timeout: 30
54
+ });
55
+ assert.deepStrictEqual(this.deployer.resources.Policy, {
56
+ ...resources.Policy,
57
+ PolicyDocument: { Statement: [] },
58
+ PolicyName: "WebdaSampleApplicationPolicy",
59
+ Roles: [{ Ref: "Role" }]
60
+ });
61
+ this.deployer.resources.ResourcesToImport = [];
62
+ this.deployer.resources.ChangeSetType = "CREATE";
63
+ await assert.rejects(() => this.deployer.defaultResources(), /ChangeSetType cannot be anything else than IMPORT if you have ResourcesToImport set/);
64
+ this.deployer.resources.ResourcesToImport = [];
65
+ this.deployer.resources.ChangeSetType = undefined;
66
+ this.deployer.resources.APIGatewayStage = {};
67
+ // @ts-ignore
68
+ this.deployer.resources.APIGatewayV2Domain = {};
69
+ // @ts-ignore
70
+ this.deployer.resources.Docker = { tag: "plop" };
71
+ this.deployer.getAWSIdentity = async () => ({
72
+ Account: "mine"
73
+ });
74
+ this.deployer.resources.APIGatewayBasePathMapping.DomainName = "webda.io.";
75
+ this.deployer.resources.APIGatewayV2ApiMapping = { DomainName: "webda.io." };
76
+ // @ts-ignore
77
+ this.deployer.resources.Statics = [{ Source: "/plop" }];
78
+ await this.deployer.defaultResources();
79
+ this.deployer.resources.AssetsBucket = undefined;
80
+ await assert.rejects(() => this.deployer.defaultResources(), /AssetsBucket must be defined/);
64
81
  }
65
- defaultResources() {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- let resources = this.deployer.resources;
68
- resources.Lambda = {};
69
- resources.APIGateway = {};
70
- resources.APIGatewayDomain = { DomainName: "webda.io" };
71
- resources.Policy = {};
72
- resources.APIGatewayBasePathMapping = {};
73
- resources = core_1.JSONUtils.duplicate(resources);
74
- yield this.deployer.defaultResources();
75
- assert.deepStrictEqual(this.deployer.resources.APIGatewayBasePathMapping, Object.assign(Object.assign({}, resources.APIGatewayDomain), { BasePath: "" }));
76
- assert.deepStrictEqual(this.deployer.resources.APIGatewayDomain, Object.assign(Object.assign({}, resources.APIGatewayDomain), { SecurityPolicy: "TLS_1_2" }));
77
- assert.deepStrictEqual(this.deployer.resources.Lambda, Object.assign(Object.assign({}, resources.Lambda), { FunctionName: "WebdaSampleApplication", Handler: "node_modules/@webda/aws/lib/deployers/lambda-entrypoint.handler", MemorySize: 2048, Role: { "Fn::GetAtt": ["Role", "Arn"] }, Runtime: cloudformation_1.LAMBDA_LATEST_VERSION, Timeout: 30 }));
78
- assert.deepStrictEqual(this.deployer.resources.Policy, Object.assign(Object.assign({}, resources.Policy), { PolicyDocument: { Statement: [] }, PolicyName: "WebdaSampleApplicationPolicy", Roles: [{ Ref: "Role" }] }));
79
- this.deployer.resources.ResourcesToImport = [];
80
- this.deployer.resources.ChangeSetType = "CREATE";
81
- yield assert.rejects(() => this.deployer.defaultResources(), /ChangeSetType cannot be anything else than IMPORT if you have ResourcesToImport set/);
82
- this.deployer.resources.ResourcesToImport = [];
83
- this.deployer.resources.ChangeSetType = undefined;
84
- this.deployer.resources.APIGatewayStage = {};
85
- // @ts-ignore
86
- this.deployer.resources.APIGatewayV2Domain = {};
87
- // @ts-ignore
88
- this.deployer.resources.Docker = { tag: "plop" };
89
- this.deployer.getAWSIdentity = () => __awaiter(this, void 0, void 0, function* () {
90
- return ({
91
- Account: "mine"
92
- });
93
- });
94
- this.deployer.resources.APIGatewayBasePathMapping.DomainName = "webda.io.";
95
- this.deployer.resources.APIGatewayV2ApiMapping = { DomainName: "webda.io." };
96
- // @ts-ignore
97
- this.deployer.resources.Statics = [{ Source: "/plop" }];
98
- yield this.deployer.defaultResources();
99
- this.deployer.resources.AssetsBucket = undefined;
100
- yield assert.rejects(() => this.deployer.defaultResources(), /AssetsBucket must be defined/);
82
+ async testSendCloudFormationTemplate() {
83
+ this.deployer.resources.AssetsBucket = "webda";
84
+ this.deployer.resources.AssetsPrefix = "plop/";
85
+ this.deployer.resources.FileName = "123";
86
+ this.deployer.template = {
87
+ fake: true
88
+ };
89
+ await this.deployer.sendCloudFormationTemplate();
90
+ assert.deepStrictEqual(this.deployer.result.CloudFormation, {
91
+ Bucket: "webda",
92
+ Key: "plop/123.json"
93
+ });
94
+ this.deployer.resources.AssetsPrefix = "/plop/";
95
+ this.deployer.resources.FileName = "123.json";
96
+ this.deployer.result = {};
97
+ await this.deployer.sendCloudFormationTemplate();
98
+ assert.deepStrictEqual(this.deployer.result.CloudFormation, {
99
+ Bucket: "webda",
100
+ Key: "plop/123.json"
101
+ });
102
+ this.deployer.resources.FileName = "123";
103
+ this.deployer.resources.Format = "YAML";
104
+ this.deployer.result = {};
105
+ await this.deployer.sendCloudFormationTemplate();
106
+ assert.deepStrictEqual(this.deployer.result.CloudFormation, {
107
+ Bucket: "webda",
108
+ Key: "plop/123.yml"
109
+ });
110
+ this.deployer.resources.FileName = "123.yml";
111
+ this.deployer.result = {};
112
+ await this.deployer.sendCloudFormationTemplate();
113
+ assert.deepStrictEqual(this.deployer.result.CloudFormation, {
114
+ Bucket: "webda",
115
+ Key: "plop/123.yml"
116
+ });
117
+ this.deployer.resources.FileName = "123.taml";
118
+ this.deployer.result = {};
119
+ await this.deployer.sendCloudFormationTemplate();
120
+ assert.deepStrictEqual(this.deployer.result.CloudFormation, {
121
+ Bucket: "webda",
122
+ Key: "plop/123.taml.yml"
123
+ });
124
+ this.deployer.resources.FileName = "123.yaml";
125
+ this.deployer.result = {};
126
+ this.deployer.resources.AssetsPrefix = "";
127
+ await this.deployer.sendCloudFormationTemplate();
128
+ assert.deepStrictEqual(this.deployer.result.CloudFormation, {
129
+ Bucket: "webda",
130
+ Key: "123.yaml"
101
131
  });
102
132
  }
103
- testSendCloudFormationTemplate() {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- this.deployer.resources.AssetsBucket = "webda";
106
- this.deployer.resources.AssetsPrefix = "plop/";
107
- this.deployer.resources.FileName = "123";
108
- this.deployer.template = {
109
- fake: true
133
+ async testDeploy() {
134
+ let resources = this.deployer.resources;
135
+ resources.Lambda = {};
136
+ resources.Resources = {};
137
+ resources.APIGateway = {};
138
+ resources.APIGatewayDomain = {
139
+ DomainName: "webda.io"
140
+ };
141
+ resources.Policy = {};
142
+ resources.Role = {};
143
+ resources.Fargate = {};
144
+ resources.Tags = [{ Key: "test", Value: "test" }];
145
+ resources.CustomResources = {
146
+ MyResource: { Type: "Test" }
147
+ };
148
+ let uploadStatics = sinon.stub(this.deployer, "uploadStatics");
149
+ let createCloudFormation = sinon.stub(this.deployer, "createCloudFormation");
150
+ let sendCloudFormation = sinon.stub(this.deployer, "sendCloudFormationTemplate");
151
+ let generateLambdaPackage = sinon.stub(this.deployer, "generateLambdaPackage");
152
+ sendCloudFormation.callsFake(async () => {
153
+ this.deployer.result.CloudFormation = {
154
+ Bucket: "plop",
155
+ Key: "mycf.json"
110
156
  };
111
- yield this.deployer.sendCloudFormationTemplate();
112
- assert.deepStrictEqual(this.deployer.result.CloudFormation, {
113
- Bucket: "webda",
114
- Key: "plop/123.json"
115
- });
116
- this.deployer.resources.AssetsPrefix = "/plop/";
117
- this.deployer.resources.FileName = "123.json";
118
- this.deployer.result = {};
119
- yield this.deployer.sendCloudFormationTemplate();
120
- assert.deepStrictEqual(this.deployer.result.CloudFormation, {
121
- Bucket: "webda",
122
- Key: "plop/123.json"
123
- });
124
- this.deployer.resources.FileName = "123";
125
- this.deployer.resources.Format = "YAML";
126
- this.deployer.result = {};
127
- yield this.deployer.sendCloudFormationTemplate();
128
- assert.deepStrictEqual(this.deployer.result.CloudFormation, {
129
- Bucket: "webda",
130
- Key: "plop/123.yml"
131
- });
132
- this.deployer.resources.FileName = "123.yml";
133
- this.deployer.result = {};
134
- yield this.deployer.sendCloudFormationTemplate();
135
- assert.deepStrictEqual(this.deployer.result.CloudFormation, {
136
- Bucket: "webda",
137
- Key: "plop/123.yml"
138
- });
139
- this.deployer.resources.FileName = "123.taml";
140
- this.deployer.result = {};
141
- yield this.deployer.sendCloudFormationTemplate();
142
- assert.deepStrictEqual(this.deployer.result.CloudFormation, {
143
- Bucket: "webda",
144
- Key: "plop/123.taml.yml"
145
- });
146
- this.deployer.resources.FileName = "123.yaml";
147
- this.deployer.result = {};
148
- this.deployer.resources.AssetsPrefix = "";
149
- yield this.deployer.sendCloudFormationTemplate();
150
- assert.deepStrictEqual(this.deployer.result.CloudFormation, {
151
- Bucket: "webda",
152
- Key: "123.yaml"
153
- });
154
157
  });
155
- }
156
- testDeploy() {
157
- return __awaiter(this, void 0, void 0, function* () {
158
- let resources = this.deployer.resources;
159
- resources.Lambda = {};
160
- resources.Resources = {};
161
- resources.APIGateway = {};
162
- resources.APIGatewayDomain = {
163
- DomainName: "webda.io"
158
+ generateLambdaPackage.callsFake(async () => {
159
+ return {
160
+ S3Bucket: "fake",
161
+ S3Key: "lambda.zip"
164
162
  };
165
- resources.Policy = {};
166
- resources.Role = {};
167
- resources.Fargate = {};
168
- resources.Tags = [{ Key: "test", Value: "test" }];
169
- resources.CustomResources = {
170
- MyResource: { Type: "Test" }
163
+ });
164
+ await this.deployer.defaultResources();
165
+ const mock = mockClient(APIGateway);
166
+ try {
167
+ mock.on(PutRestApiCommand).resolves({});
168
+ this.deployer.resources.Docker = {
169
+ tag: "plop",
170
+ includeRepository: false
171
171
  };
172
- let uploadStatics = sinon.stub(this.deployer, "uploadStatics");
173
- let createCloudFormation = sinon.stub(this.deployer, "createCloudFormation");
174
- let sendCloudFormation = sinon.stub(this.deployer, "sendCloudFormationTemplate");
175
- let generateLambdaPackage = sinon.stub(this.deployer, "generateLambdaPackage");
176
- sendCloudFormation.callsFake(() => __awaiter(this, void 0, void 0, function* () {
177
- this.deployer.result.CloudFormation = {
178
- Bucket: "plop",
179
- Key: "mycf.json"
180
- };
181
- }));
182
- generateLambdaPackage.callsFake(() => __awaiter(this, void 0, void 0, function* () {
183
- return {
184
- S3Bucket: "fake",
185
- S3Key: "lambda.zip"
186
- };
187
- }));
188
- yield this.deployer.defaultResources();
189
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_api_gateway_1.APIGateway);
190
- try {
191
- mock.on(client_api_gateway_1.PutRestApiCommand).resolves({});
192
- console.log("Launch deploy", this.deployer.uploadStatics);
193
- this.deployer.resources.Docker = {
194
- tag: "plop",
195
- includeRepository: false
196
- };
197
- this.deployer.resources.APIGatewayImportOpenApi = "yop";
198
- sinon.stub(this.deployer.manager, "run").callsFake(() => __awaiter(this, void 0, void 0, function* () { }));
199
- yield this.deployer.deploy();
200
- console.log("Launch deploy done");
201
- assert.strictEqual(sendCloudFormation.calledOnce, true);
202
- assert.strictEqual(generateLambdaPackage.calledOnce, true);
203
- yield this.deployer.sleep(0.001);
204
- }
205
- finally {
206
- mock.restore();
172
+ this.deployer.resources.APIGatewayImportOpenApi = "yop";
173
+ sinon.stub(this.deployer.manager, "run").callsFake(async () => { });
174
+ await this.deployer.deploy();
175
+ assert.strictEqual(sendCloudFormation.calledOnce, true);
176
+ assert.strictEqual(generateLambdaPackage.calledOnce, true);
177
+ await this.deployer.sleep(0.001);
178
+ }
179
+ finally {
180
+ mock.restore();
181
+ }
182
+ }
183
+ async testDeleteCloudFormation() {
184
+ this.mocks["deleteStack"] = sinon.stub().resolves({});
185
+ this.mocks["describeStacks"] = sinon.stub().callsFake(async () => {
186
+ if (this.mocks["describeStacks"].callCount > 1) {
187
+ throw new Error();
207
188
  }
189
+ return {};
208
190
  });
191
+ this.mocks["waitFor"] = sinon.stub(this.deployer, "waitFor").callsFake(async (c) => {
192
+ await c(() => { });
193
+ await c(() => { });
194
+ });
195
+ const mock = mockClient(CloudFormation)
196
+ .on(DeleteStackCommand)
197
+ .callsFake(this.mocks["deleteStack"])
198
+ .on(DescribeStacksCommand)
199
+ .callsFake(this.mocks["describeStacks"]);
200
+ try {
201
+ await this.deployer.deleteCloudFormation();
202
+ assert.strictEqual(this.mocks["deleteStack"].calledOnce, true);
203
+ assert.strictEqual(this.mocks["waitFor"].calledOnce, true);
204
+ assert.strictEqual(this.mocks["describeStacks"].calledTwice, true);
205
+ }
206
+ finally {
207
+ mock.restore();
208
+ }
209
209
  }
210
- testDeleteCloudFormation() {
211
- return __awaiter(this, void 0, void 0, function* () {
212
- this.mocks["deleteStack"] = sinon.stub().resolves({});
213
- this.mocks["describeStacks"] = sinon.stub().callsFake(() => __awaiter(this, void 0, void 0, function* () {
214
- if (this.mocks["describeStacks"].callCount > 1) {
215
- throw new Error();
210
+ async testInit() {
211
+ let logs = [];
212
+ let console = {
213
+ app: {
214
+ getAppPath: () => {
215
+ return "./noexisting";
216
216
  }
217
- return {};
218
- }));
219
- this.mocks["waitFor"] = sinon.stub(this.deployer, "waitFor").callsFake((c) => __awaiter(this, void 0, void 0, function* () {
220
- yield c(() => { });
221
- yield c(() => { });
222
- }));
223
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_cloudformation_1.CloudFormation)
224
- .on(client_cloudformation_1.DeleteStackCommand)
225
- .callsFake(this.mocks["deleteStack"])
226
- .on(client_cloudformation_1.DescribeStacksCommand)
227
- .callsFake(this.mocks["describeStacks"]);
228
- try {
229
- yield this.deployer.deleteCloudFormation();
230
- assert.strictEqual(this.mocks["deleteStack"].calledOnce, true);
231
- assert.strictEqual(this.mocks["waitFor"].calledOnce, true);
232
- assert.strictEqual(this.mocks["describeStacks"].calledTwice, true);
217
+ },
218
+ log: (...args) => {
219
+ logs.push(args);
233
220
  }
234
- finally {
235
- mock.restore();
221
+ };
222
+ let caller = sinon.stub().callsFake(async () => {
223
+ if (caller.callCount === 1) {
224
+ throw new Error("Bad");
236
225
  }
226
+ return { Account: "myAccount" };
237
227
  });
228
+ let saver = sinon.stub(JSONUtils, "saveFile").callsFake(() => { });
229
+ const mocks = [];
230
+ try {
231
+ mocks.push(mockClient(STS).on(GetCallerIdentityCommand).callsFake(caller));
232
+ let stub = sinon.stub().resolves({});
233
+ mocks.push(mockClient(CloudFormation).on(CreateStackCommand).callsFake(stub));
234
+ assert.ok((await CloudFormationDeployer.init(console)) === -1);
235
+ assert.deepStrictEqual(logs[0], ["ERROR", "package.json not found"]);
236
+ console.app.getAppPath = () => "./test/package.json";
237
+ assert.ok((await CloudFormationDeployer.init(console)) === -1);
238
+ assert.deepStrictEqual(logs[1], [
239
+ "ERROR",
240
+ "Cannot retrieve your AWS credentials, make sure to have a correct AWS setup"
241
+ ]);
242
+ logs = [];
243
+ assert.ok((await CloudFormationDeployer.init(console)) === 0);
244
+ assert.strictEqual(saver.getCall(0).args[0].webda.aws.AssetsBucket, "webda-webda-testor-assets");
245
+ assert.strictEqual(saver.getCall(0).args[0].webda.aws.Repository, "webda-webda-testor");
246
+ console.app.getAppPath = () => "./test/package-initiated.json";
247
+ logs = [];
248
+ assert.ok((await CloudFormationDeployer.init(console)) === -1);
249
+ assert.deepStrictEqual(logs[0], ["WARN", "Default information are already in your package.json"]);
250
+ }
251
+ finally {
252
+ mocks.forEach(m => m.restore());
253
+ }
238
254
  }
239
- testInit() {
240
- return __awaiter(this, void 0, void 0, function* () {
241
- let logs = [];
242
- let console = {
243
- app: {
244
- getAppPath: () => {
245
- return "./noexisting";
246
- }
255
+ async createCloudFormation() {
256
+ let describeChangeSetResult = { Status: "ROLLBACK_COMPLETE" };
257
+ let describeStackEventsResult = {
258
+ StackEvents: [
259
+ { EventId: "123", LogicalResourceId: this.deployer.resources.StackName, ResourceStatus: "IN_PROGRESS" }
260
+ ]
261
+ };
262
+ let logs = sinon.stub(this.deployer.logger, "log");
263
+ sinon.stub(this.deployer, "waitFor").callsFake(callback => {
264
+ return new Promise((resolve, reject) => {
265
+ callback(resolve, reject);
266
+ });
267
+ });
268
+ const mocks = [];
269
+ sinon.stub(this.deployer, "createCloudFormationChangeSet").callsFake(async () => "mychange");
270
+ const mock = mockClient(CloudFormation)
271
+ .on(DescribeChangeSetCommand)
272
+ .resolves(describeChangeSetResult)
273
+ .on(ExecuteChangeSetCommand)
274
+ .resolves({})
275
+ .on(DescribeStackEventsCommand)
276
+ .callsFake(async () => {
277
+ let res = { ...describeStackEventsResult, StackEvents: [...describeStackEventsResult.StackEvents] };
278
+ describeStackEventsResult.StackEvents.unshift({
279
+ EventId: "123",
280
+ ResourceType: "any",
281
+ LogicalResourceId: this.deployer.resources.StackName,
282
+ ResourceStatus: "UPDATE_ROLLBACK_COMPLETE"
283
+ });
284
+ return res;
285
+ })
286
+ .on(ListStackResourcesCommand)
287
+ .resolves({
288
+ StackResourceSummaries: [
289
+ {
290
+ ResourceType: "AWS::ApiGateway::Stage",
291
+ PhysicalResourceId: "stage",
292
+ LogicalResourceId: "",
293
+ LastUpdatedTimestamp: new Date(),
294
+ ResourceStatus: ""
247
295
  },
248
- log: (...args) => {
249
- logs.push(args);
296
+ {
297
+ ResourceType: "AWS::ApiGateway::RestApi",
298
+ PhysicalResourceId: "restApi",
299
+ LogicalResourceId: "",
300
+ LastUpdatedTimestamp: new Date(),
301
+ ResourceStatus: ""
250
302
  }
251
- };
252
- let caller = sinon.stub().callsFake(() => __awaiter(this, void 0, void 0, function* () {
253
- if (caller.callCount === 1) {
254
- throw new Error("Bad");
255
- }
256
- return { Account: "myAccount" };
257
- }));
258
- let saver = sinon.stub(core_1.JSONUtils, "saveFile").callsFake(() => { });
259
- const mocks = [];
260
- try {
261
- mocks.push((0, aws_sdk_client_mock_1.mockClient)(client_sts_1.STS).on(client_sts_1.GetCallerIdentityCommand).callsFake(caller));
262
- let stub = sinon.stub().resolves({});
263
- mocks.push((0, aws_sdk_client_mock_1.mockClient)(client_cloudformation_1.CloudFormation).on(client_cloudformation_1.CreateStackCommand).callsFake(stub));
264
- assert.ok((yield cloudformation_1.CloudFormationDeployer.init(console)) === -1);
265
- assert.deepStrictEqual(logs[0], ["ERROR", "package.json not found"]);
266
- console.app.getAppPath = () => "./test/package.json";
267
- assert.ok((yield cloudformation_1.CloudFormationDeployer.init(console)) === -1);
268
- assert.deepStrictEqual(logs[1], [
269
- "ERROR",
270
- "Cannot retrieve your AWS credentials, make sure to have a correct AWS setup"
271
- ]);
272
- logs = [];
273
- assert.ok((yield cloudformation_1.CloudFormationDeployer.init(console)) === 0);
274
- assert.strictEqual(saver.getCall(0).args[0].webda.aws.AssetsBucket, "webda-webda-testor-assets");
275
- assert.strictEqual(saver.getCall(0).args[0].webda.aws.Repository, "webda-webda-testor");
276
- console.app.getAppPath = () => "./test/package-initiated.json";
277
- logs = [];
278
- assert.ok((yield cloudformation_1.CloudFormationDeployer.init(console)) === -1);
279
- assert.deepStrictEqual(logs[0], ["WARN", "Default information are already in your package.json"]);
280
- }
281
- finally {
282
- mocks.forEach(m => m.restore());
283
- }
303
+ ]
284
304
  });
305
+ mocks.push(mock);
306
+ try {
307
+ let createDeployment = sinon.stub().resolves({});
308
+ mocks.push(mockClient(APIGateway).on(CreateDeploymentCommand).callsFake(createDeployment));
309
+ // First scenario we have a 'ROLLBACK_COMPLETE', an error occured
310
+ await assert.rejects(() => this.deployer.createCloudFormation());
311
+ // 'FAILED' scenario with unknown error
312
+ logs.resetHistory();
313
+ describeChangeSetResult.Status = "FAILED";
314
+ describeChangeSetResult.StatusReason = "plop";
315
+ await this.deployer.createCloudFormation();
316
+ assert.deepStrictEqual(logs.getCall(1).args, ["ERROR", "Cannot execute ChangeSet:", "plop"]);
317
+ // 'FAILED' scenario because no changes to be made
318
+ describeChangeSetResult.StatusReason =
319
+ "The submitted information didn't contain changes. Submit different information to create a change set.";
320
+ logs.resetHistory();
321
+ await this.deployer.createCloudFormation();
322
+ assert.deepStrictEqual(logs.getCall(1).args, ["INFO", "No changes to be made"]);
323
+ // 'CREATE_COMPLETE' scenario
324
+ logs.resetHistory();
325
+ describeChangeSetResult.Status = "CREATE_COMPLETE";
326
+ describeChangeSetResult.Changes = [
327
+ { Type: "Resource", ResourceChange: { Action: "Create", ResourceType: "Fake", LogicalResourceId: "FakeId" } },
328
+ { Type: "Plop" }
329
+ ];
330
+ await this.deployer.createCloudFormation();
331
+ assert.deepStrictEqual(createDeployment.getCall(0).args[0], { restApiId: "restApi", stageName: "stage" });
332
+ // 'TIMEOUT'
333
+ this.deployer.sleep = async () => { };
334
+ describeStackEventsResult.StackEvents = [];
335
+ mock.on(DescribeStackEventsCommand).resolves(describeStackEventsResult);
336
+ await this.deployer.createCloudFormation();
337
+ assert.ok(createDeployment.callCount === 1);
338
+ }
339
+ finally {
340
+ mocks.forEach(m => m.restore());
341
+ }
285
342
  }
286
- createCloudFormation() {
287
- return __awaiter(this, void 0, void 0, function* () {
288
- let describeChangeSetResult = { Status: "ROLLBACK_COMPLETE" };
289
- let describeStackEventsResult = {
290
- StackEvents: [
291
- { EventId: "123", LogicalResourceId: this.deployer.resources.StackName, ResourceStatus: "IN_PROGRESS" }
292
- ]
293
- };
294
- let logs = sinon.stub(this.deployer.logger, "log");
343
+ async uploadStatics() {
344
+ sinon.stub(this.deployer, "putFolderOnBucket").callsFake(async () => { });
345
+ this.deployer.resources.Statics = [
346
+ // @ts-ignore
347
+ { Source: "//", AssetsPath: "//" }
348
+ ];
349
+ await this.deployer.uploadStatics();
350
+ }
351
+ async generateLambdaPackage() {
352
+ let run = sinon.stub(this.deployer.manager, "run").callsFake(async () => { });
353
+ try {
354
+ this.deployer.resources.KeepPackage = true;
355
+ await this.deployer.generateLambdaPackage();
356
+ }
357
+ finally {
358
+ run.restore();
359
+ }
360
+ }
361
+ async createCloudFormationChangeSet() {
362
+ let describeStacksResult = { Stacks: [{ StackStatus: "ZZ", StackName: "", CreationTime: new Date() }] };
363
+ this.deployer.result.CloudFormation = {
364
+ Bucket: "Bucket",
365
+ Key: "mykey"
366
+ };
367
+ const mock = mockClient(CloudFormation)
368
+ .on(CreateChangeSetCommand)
369
+ .resolves({})
370
+ .on(DescribeStacksCommand)
371
+ .callsFake(async () => describeStacksResult)
372
+ .on(DeleteChangeSetCommand)
373
+ .resolves({});
374
+ sinon.stub(this.deployer, "deleteCloudFormation").callsFake(async () => { });
375
+ try {
376
+ let cloudformation = new CloudFormation({ credentials: defaultCreds });
377
+ // Nominal case
378
+ await this.deployer.createCloudFormationChangeSet(cloudformation);
379
+ // With error
380
+ let testError;
381
+ let errorFirst = sinon.stub().callsFake(async () => {
382
+ if (errorFirst.callCount === 1) {
383
+ throw testError;
384
+ }
385
+ else {
386
+ return {};
387
+ }
388
+ });
389
+ mock.on(CreateChangeSetCommand).callsFake(errorFirst);
390
+ testError = new Error("plop is in ROLLBACK_COMPLETE state and can not be updated.");
391
+ // Should still go through with a bugous stack
392
+ await this.deployer.createCloudFormationChangeSet(cloudformation);
393
+ // Non-existing stack
394
+ testError = new Error(`Stack [${this.deployer.resources.StackName}] does not exist`);
395
+ errorFirst.resetHistory();
396
+ await this.deployer.createCloudFormationChangeSet(cloudformation);
397
+ // Change set exist
398
+ testError = new Error();
399
+ testError.code = "AlreadyExistsException";
400
+ errorFirst.resetHistory();
401
+ await this.deployer.createCloudFormationChangeSet(cloudformation);
402
+ // True error
403
+ testError = new Error("Unknown");
404
+ errorFirst.resetHistory();
405
+ await assert.rejects(() => this.deployer.createCloudFormationChangeSet(cloudformation), /Unknown/);
406
+ // Test with stack status
407
+ testError = new Error("bouzouf state and can not be updated.");
295
408
  sinon.stub(this.deployer, "waitFor").callsFake(callback => {
296
- return new Promise((resolve, reject) => {
297
- callback(resolve, reject);
409
+ return new Promise(async (resolve, reject) => {
410
+ if (!(await callback(resolve, reject))) {
411
+ reject("BAD");
412
+ }
298
413
  });
299
414
  });
300
- const mocks = [];
301
- sinon.stub(this.deployer, "createCloudFormationChangeSet").callsFake(() => __awaiter(this, void 0, void 0, function* () { return "mychange"; }));
302
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_cloudformation_1.CloudFormation)
303
- .on(client_cloudformation_1.DescribeChangeSetCommand)
304
- .resolves(describeChangeSetResult)
305
- .on(client_cloudformation_1.ExecuteChangeSetCommand)
306
- .resolves({})
307
- .on(client_cloudformation_1.DescribeStackEventsCommand)
308
- .callsFake(() => __awaiter(this, void 0, void 0, function* () {
309
- let res = Object.assign(Object.assign({}, describeStackEventsResult), { StackEvents: [...describeStackEventsResult.StackEvents] });
310
- describeStackEventsResult.StackEvents.unshift({
311
- EventId: "123",
312
- ResourceType: "any",
313
- LogicalResourceId: this.deployer.resources.StackName,
314
- ResourceStatus: "UPDATE_ROLLBACK_COMPLETE"
315
- });
316
- return res;
317
- }))
318
- .on(client_cloudformation_1.ListStackResourcesCommand)
319
- .resolves({
320
- StackResourceSummaries: [
321
- {
322
- ResourceType: "AWS::ApiGateway::Stage",
323
- PhysicalResourceId: "stage",
324
- LogicalResourceId: "",
325
- LastUpdatedTimestamp: new Date(),
326
- ResourceStatus: ""
327
- },
415
+ errorFirst.resetHistory();
416
+ await assert.rejects(() => this.deployer.createCloudFormationChangeSet(cloudformation), /BAD/);
417
+ describeStacksResult = { Stacks: [{ StackStatus: "ANY_COMPLETE", StackName: "", CreationTime: new Date() }] };
418
+ errorFirst.resetHistory();
419
+ await this.deployer.createCloudFormationChangeSet(cloudformation);
420
+ describeStacksResult = { Stacks: [] };
421
+ errorFirst.resetHistory();
422
+ await this.deployer.createCloudFormationChangeSet(cloudformation);
423
+ }
424
+ finally {
425
+ mock.restore();
426
+ }
427
+ }
428
+ async createStatic() {
429
+ this.deployer.template = { Resources: {} };
430
+ await this.deployer.createStatic({ Bucket: { Tags: {} }, DomainName: "webda.io" });
431
+ assert.deepStrictEqual(this.deployer.template.Resources[`StaticwebdaioBucket`], {
432
+ Type: "AWS::S3::Bucket",
433
+ Properties: {
434
+ BucketName: "webda.io",
435
+ Tags: [
328
436
  {
329
- ResourceType: "AWS::ApiGateway::RestApi",
330
- PhysicalResourceId: "restApi",
331
- LogicalResourceId: "",
332
- LastUpdatedTimestamp: new Date(),
333
- ResourceStatus: ""
437
+ Key: "test",
438
+ Value: "webda3"
334
439
  }
335
440
  ]
336
- });
337
- mocks.push(mock);
338
- try {
339
- let createDeployment = sinon.stub().resolves({});
340
- mocks.push((0, aws_sdk_client_mock_1.mockClient)(client_api_gateway_1.APIGateway).on(client_api_gateway_1.CreateDeploymentCommand).callsFake(createDeployment));
341
- // First scenario we have a 'ROLLBACK_COMPLETE', an error occured
342
- yield assert.rejects(() => this.deployer.createCloudFormation());
343
- // 'FAILED' scenario with unknown error
344
- logs.resetHistory();
345
- describeChangeSetResult.Status = "FAILED";
346
- describeChangeSetResult.StatusReason = "plop";
347
- yield this.deployer.createCloudFormation();
348
- assert.deepStrictEqual(logs.getCall(1).args, ["ERROR", "Cannot execute ChangeSet:", "plop"]);
349
- // 'FAILED' scenario because no changes to be made
350
- describeChangeSetResult.StatusReason =
351
- "The submitted information didn't contain changes. Submit different information to create a change set.";
352
- logs.resetHistory();
353
- yield this.deployer.createCloudFormation();
354
- assert.deepStrictEqual(logs.getCall(1).args, ["INFO", "No changes to be made"]);
355
- // 'CREATE_COMPLETE' scenario
356
- logs.resetHistory();
357
- describeChangeSetResult.Status = "CREATE_COMPLETE";
358
- describeChangeSetResult.Changes = [
359
- { Type: "Resource", ResourceChange: { Action: "Create", ResourceType: "Fake", LogicalResourceId: "FakeId" } },
360
- { Type: "Plop" }
361
- ];
362
- yield this.deployer.createCloudFormation();
363
- assert.deepStrictEqual(createDeployment.getCall(0).args[0], { restApiId: "restApi", stageName: "stage" });
364
- // 'TIMEOUT'
365
- this.deployer.sleep = () => __awaiter(this, void 0, void 0, function* () { });
366
- describeStackEventsResult.StackEvents = [];
367
- mock.on(client_cloudformation_1.DescribeStackEventsCommand).resolves(describeStackEventsResult);
368
- yield this.deployer.createCloudFormation();
369
- assert.ok(createDeployment.callCount === 1);
370
- }
371
- finally {
372
- mocks.forEach(m => m.restore());
373
441
  }
374
442
  });
375
443
  }
376
- uploadStatics() {
377
- return __awaiter(this, void 0, void 0, function* () {
378
- sinon.stub(this.deployer, "putFolderOnBucket").callsFake(() => __awaiter(this, void 0, void 0, function* () { }));
379
- this.deployer.resources.Statics = [
380
- // @ts-ignore
381
- { Source: "//", AssetsPath: "//" }
382
- ];
383
- yield this.deployer.uploadStatics();
384
- });
385
- }
386
- generateLambdaPackage() {
387
- return __awaiter(this, void 0, void 0, function* () {
388
- let run = sinon.stub(this.deployer.manager, "run").callsFake(() => __awaiter(this, void 0, void 0, function* () { }));
389
- let unlink = sinon.stub(require("fs"), "unlinkSync").callsFake(() => __awaiter(this, void 0, void 0, function* () { }));
390
- try {
391
- this.deployer.resources.KeepPackage = false;
392
- yield this.deployer.generateLambdaPackage();
393
- this.deployer.resources.KeepPackage = true;
394
- yield this.deployer.generateLambdaPackage();
395
- }
396
- finally {
397
- unlink.restore();
398
- run.restore();
399
- }
400
- });
401
- }
402
- createCloudFormationChangeSet() {
403
- return __awaiter(this, void 0, void 0, function* () {
404
- let describeStacksResult = { Stacks: [{ StackStatus: "ZZ", StackName: "", CreationTime: new Date() }] };
405
- this.deployer.result.CloudFormation = {
406
- Bucket: "Bucket",
407
- Key: "mykey"
408
- };
409
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_cloudformation_1.CloudFormation)
410
- .on(client_cloudformation_1.CreateChangeSetCommand)
411
- .resolves({})
412
- .on(client_cloudformation_1.DescribeStacksCommand)
413
- .callsFake(() => __awaiter(this, void 0, void 0, function* () { return describeStacksResult; }))
414
- .on(client_cloudformation_1.DeleteChangeSetCommand)
415
- .resolves({});
416
- sinon.stub(this.deployer, "deleteCloudFormation").callsFake(() => __awaiter(this, void 0, void 0, function* () { }));
417
- try {
418
- let cloudformation = new client_cloudformation_1.CloudFormation({ credentials: index_spec_1.defaultCreds });
419
- // Nominal case
420
- yield this.deployer.createCloudFormationChangeSet(cloudformation);
421
- // With error
422
- let testError;
423
- let errorFirst = sinon.stub().callsFake(() => __awaiter(this, void 0, void 0, function* () {
424
- if (errorFirst.callCount === 1) {
425
- throw testError;
426
- }
427
- else {
428
- return {};
429
- }
430
- }));
431
- mock.on(client_cloudformation_1.CreateChangeSetCommand).callsFake(errorFirst);
432
- testError = new Error("plop is in ROLLBACK_COMPLETE state and can not be updated.");
433
- // Should still go through with a bugous stack
434
- yield this.deployer.createCloudFormationChangeSet(cloudformation);
435
- // Non-existing stack
436
- testError = new Error(`Stack [${this.deployer.resources.StackName}] does not exist`);
437
- errorFirst.resetHistory();
438
- yield this.deployer.createCloudFormationChangeSet(cloudformation);
439
- // Change set exist
440
- testError = new Error();
441
- testError.code = "AlreadyExistsException";
442
- errorFirst.resetHistory();
443
- yield this.deployer.createCloudFormationChangeSet(cloudformation);
444
- // True error
445
- testError = new Error("Unknown");
446
- errorFirst.resetHistory();
447
- yield assert.rejects(() => this.deployer.createCloudFormationChangeSet(cloudformation), /Unknown/);
448
- // Test with stack status
449
- testError = new Error("bouzouf state and can not be updated.");
450
- sinon.stub(this.deployer, "waitFor").callsFake(callback => {
451
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
452
- if (!(yield callback(resolve, reject))) {
453
- reject("BAD");
454
- }
455
- }));
456
- });
457
- errorFirst.resetHistory();
458
- yield assert.rejects(() => this.deployer.createCloudFormationChangeSet(cloudformation), /BAD/);
459
- describeStacksResult = { Stacks: [{ StackStatus: "ANY_COMPLETE", StackName: "", CreationTime: new Date() }] };
460
- errorFirst.resetHistory();
461
- yield this.deployer.createCloudFormationChangeSet(cloudformation);
462
- describeStacksResult = { Stacks: [] };
463
- errorFirst.resetHistory();
464
- yield this.deployer.createCloudFormationChangeSet(cloudformation);
465
- }
466
- finally {
467
- mock.restore();
468
- }
469
- });
470
- }
471
- createStatic() {
472
- return __awaiter(this, void 0, void 0, function* () {
473
- this.deployer.template = { Resources: {} };
474
- yield this.deployer.createStatic({ Bucket: { Tags: {} }, DomainName: "webda.io" });
475
- assert.deepStrictEqual(this.deployer.template.Resources[`StaticwebdaioBucket`], {
476
- Type: "AWS::S3::Bucket",
477
- Properties: {
478
- BucketName: "webda.io",
479
- Tags: [
480
- {
481
- Key: "test",
482
- Value: "webda3"
483
- }
484
- ]
485
- }
486
- });
487
- });
488
- }
489
- APIGatewayDomain() {
490
- return __awaiter(this, void 0, void 0, function* () {
491
- this.deployer.template = { Resources: {} };
492
- this.deployer.resources.APIGatewayDomain.EndpointConfiguration = {
493
- Types: ["EDGE"]
494
- };
495
- sinon.stub(this.deployer, "createCloudFormationDNSEntry");
496
- yield this.deployer.APIGatewayDomain();
497
- });
444
+ async APIGatewayDomain() {
445
+ this.deployer.template = { Resources: {} };
446
+ this.deployer.resources.APIGatewayDomain.EndpointConfiguration = {
447
+ Types: ["EDGE"]
448
+ };
449
+ sinon.stub(this.deployer, "createCloudFormationDNSEntry");
450
+ await this.deployer.APIGatewayDomain();
498
451
  }
499
- createCloudFormationDNSEntry() {
500
- return __awaiter(this, void 0, void 0, function* () {
501
- this.mocks.getZoneForDomainName.callsFake(() => __awaiter(this, void 0, void 0, function* () {
502
- return undefined;
503
- }));
504
- yield this.deployer.createCloudFormationDNSEntry(undefined, "plop.com", undefined);
452
+ async createCloudFormationDNSEntry() {
453
+ this.mocks.getZoneForDomainName.callsFake(async () => {
454
+ return undefined;
505
455
  });
456
+ await this.deployer.createCloudFormationDNSEntry(undefined, "plop.com", undefined);
506
457
  }
507
458
  };
508
459
  __decorate([
509
- mocha_1.test
460
+ test
510
461
  ], CloudFormationDeployerTest.prototype, "defaultResources", null);
511
462
  __decorate([
512
- mocha_1.test
463
+ test
513
464
  ], CloudFormationDeployerTest.prototype, "testSendCloudFormationTemplate", null);
514
465
  __decorate([
515
- mocha_1.test
466
+ test
516
467
  ], CloudFormationDeployerTest.prototype, "testDeploy", null);
517
468
  __decorate([
518
- mocha_1.test
469
+ test
519
470
  ], CloudFormationDeployerTest.prototype, "testDeleteCloudFormation", null);
520
471
  __decorate([
521
- mocha_1.test
472
+ test
522
473
  ], CloudFormationDeployerTest.prototype, "testInit", null);
523
474
  __decorate([
524
- mocha_1.test
475
+ test
525
476
  ], CloudFormationDeployerTest.prototype, "createCloudFormation", null);
526
477
  __decorate([
527
- mocha_1.test
478
+ test
528
479
  ], CloudFormationDeployerTest.prototype, "uploadStatics", null);
529
480
  __decorate([
530
- mocha_1.test
481
+ test
531
482
  ], CloudFormationDeployerTest.prototype, "generateLambdaPackage", null);
532
483
  __decorate([
533
- mocha_1.test
484
+ test
534
485
  ], CloudFormationDeployerTest.prototype, "createCloudFormationChangeSet", null);
535
486
  __decorate([
536
- mocha_1.test
487
+ test
537
488
  ], CloudFormationDeployerTest.prototype, "createStatic", null);
538
489
  __decorate([
539
- mocha_1.test
490
+ test
540
491
  ], CloudFormationDeployerTest.prototype, "APIGatewayDomain", null);
541
492
  __decorate([
542
- mocha_1.test
493
+ test
543
494
  ], CloudFormationDeployerTest.prototype, "createCloudFormationDNSEntry", null);
544
495
  CloudFormationDeployerTest = __decorate([
545
- mocha_1.suite
496
+ suite
546
497
  ], CloudFormationDeployerTest);
547
498
  //# sourceMappingURL=cloudformation.spec.js.map