@webda/aws 2.0.0-beta.2 → 2.0.1

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 +2 -2
  2. package/lib/deployers/cloudformation.js +672 -693
  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.js +13 -52
  14. package/lib/deployers/lambdapackager.js.map +1 -1
  15. package/lib/deployers/lambdapackager.spec.js +25 -61
  16. package/lib/deployers/lambdapackager.spec.js.map +1 -1
  17. package/lib/index.d.ts +1 -1
  18. package/lib/index.js +1 -17
  19. package/lib/index.js.map +1 -1
  20. package/lib/index.spec.d.ts +1 -1
  21. package/lib/index.spec.js +28 -75
  22. package/lib/index.spec.js.map +1 -1
  23. package/lib/services/aws-mixin.d.ts +2 -0
  24. package/lib/services/aws-mixin.js +2 -7
  25. package/lib/services/aws-mixin.js.map +1 -1
  26. package/lib/services/cloudwatchlogger.d.ts +4 -2
  27. package/lib/services/cloudwatchlogger.js +63 -103
  28. package/lib/services/cloudwatchlogger.js.map +1 -1
  29. package/lib/services/cloudwatchlogger.spec.js +57 -100
  30. package/lib/services/cloudwatchlogger.spec.js.map +1 -1
  31. package/lib/services/dynamodb.d.ts +5 -3
  32. package/lib/services/dynamodb.js +458 -498
  33. package/lib/services/dynamodb.js.map +1 -1
  34. package/lib/services/dynamodb.spec.d.ts +2 -2
  35. package/lib/services/dynamodb.spec.js +231 -302
  36. package/lib/services/dynamodb.spec.js.map +1 -1
  37. package/lib/services/index.d.ts +9 -9
  38. package/lib/services/index.js +8 -24
  39. package/lib/services/index.js.map +1 -1
  40. package/lib/services/lambdacaller.d.ts +3 -1
  41. package/lib/services/lambdacaller.js +16 -29
  42. package/lib/services/lambdacaller.js.map +1 -1
  43. package/lib/services/lambdacaller.spec.js +43 -81
  44. package/lib/services/lambdacaller.spec.js.map +1 -1
  45. package/lib/services/lambdaserver.d.ts +1 -8
  46. package/lib/services/lambdaserver.js +168 -206
  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 +6 -8
  65. package/lib/services/sqsqueue.js +70 -98
  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 +48 -0
@@ -1,67 +1,29 @@
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
- exports.MockAWSDeployerMethods = void 0;
42
- const client_acm_1 = require("@aws-sdk/client-acm");
43
- const client_ec2_1 = require("@aws-sdk/client-ec2");
44
- const client_route_53_1 = require("@aws-sdk/client-route-53");
45
- const client_s3_1 = require("@aws-sdk/client-s3");
46
- const client_sts_1 = require("@aws-sdk/client-sts");
47
- const mocha_1 = require("@testdeck/mocha");
48
- const core_1 = require("@webda/core");
49
- const deployertest_1 = require("@webda/shell/lib/deployers/deployertest");
50
- const assert = __importStar(require("assert"));
51
- const aws_sdk_client_mock_1 = require("aws-sdk-client-mock");
52
- const sinon = __importStar(require("sinon"));
53
- const _1 = require(".");
54
- class TestAWSDeployer extends _1.AWSDeployer {
55
- deploy() {
56
- return __awaiter(this, void 0, void 0, function* () { });
57
- }
58
- restrictedCall(method, ...args) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- return this[method](...args);
61
- });
7
+ import { ACM, DescribeCertificateCommand, ListCertificatesCommand, RequestCertificateCommand } from "@aws-sdk/client-acm";
8
+ import { DescribeSubnetsCommand, DescribeVpcsCommand, EC2 } from "@aws-sdk/client-ec2";
9
+ import { ChangeResourceRecordSetsCommand, ListHostedZonesCommand, Route53 } from "@aws-sdk/client-route-53";
10
+ import { CreateBucketCommand, HeadBucketCommand, ListObjectsV2Command, NotFound, PutBucketTaggingCommand, PutObjectCommand, S3 } from "@aws-sdk/client-s3";
11
+ import { GetCallerIdentityCommand, STS } from "@aws-sdk/client-sts";
12
+ import { suite, test } from "@testdeck/mocha";
13
+ import { CacheService, getCommonJS } from "@webda/core";
14
+ import { DeployerTest } from "@webda/shell/lib/deployers/deployertest.js";
15
+ import * as assert from "assert";
16
+ import { mockClient } from "aws-sdk-client-mock";
17
+ import * as sinon from "sinon";
18
+ import { AWSDeployer } from "./index.js";
19
+ const { __dirname, __filename } = getCommonJS(import.meta.url);
20
+ class TestAWSDeployer extends AWSDeployer {
21
+ async deploy() { }
22
+ async restrictedCall(method, ...args) {
23
+ return this[method](...args);
62
24
  }
63
25
  }
64
- function MockAWSDeployerMethods(service, test) {
26
+ export function MockAWSDeployerMethods(service, test) {
65
27
  test.mocks["putFilesOnBucket"] = sinon.stub(service, "putFilesOnBucket").resolves();
66
28
  test.mocks["createBucket"] = sinon.stub(service, "createBucket").resolves();
67
29
  test.mocks["doCreateCertificate"] = sinon.stub(service, "doCreateCertificate").resolves({});
@@ -84,12 +46,9 @@ function MockAWSDeployerMethods(service, test) {
84
46
  Statement: []
85
47
  });
86
48
  }
87
- exports.MockAWSDeployerMethods = MockAWSDeployerMethods;
88
- let AWSDeployerTest = class AWSDeployerTest extends deployertest_1.DeployerTest {
89
- getDeployer(manager) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- return new TestAWSDeployer(manager, {});
92
- });
49
+ let AWSDeployerTest = class AWSDeployerTest extends DeployerTest {
50
+ async getDeployer(manager) {
51
+ return new TestAWSDeployer(manager, {});
93
52
  }
94
53
  mapToArrayTags() {
95
54
  let deployer = new TestAWSDeployer(this.manager, { Tags: { Test: "Plop" } });
@@ -98,473 +57,449 @@ let AWSDeployerTest = class AWSDeployerTest extends deployertest_1.DeployerTest
98
57
  { Key: "Test", Value: "Plop" }
99
58
  ]);
100
59
  }
101
- putFilesOnBucket() {
102
- return __awaiter(this, void 0, void 0, function* () {
103
- yield this.deployer.putFilesOnBucket("plop", []);
104
- yield assert.rejects(
105
- // @ts-ignore
106
- () => this.deployer.putFilesOnBucket("plop", [{ key: "/test" }]), /Should have src and key defined/);
107
- let Contents = [{ Key: "awsevents.js", Size: 587, ETag: '"312d05552187d3fdfdda3860fbeef48f"' }];
108
- let stub = sinon.stub().resolves({ Contents });
109
- // Fake any uploads
110
- let uploads = [];
111
- (0, aws_sdk_client_mock_1.mockClient)(client_s3_1.S3)
112
- .on(client_s3_1.ListObjectsV2Command)
113
- .callsFake(stub)
114
- .on(client_s3_1.PutObjectCommand)
115
- .callsFake(arg => {
116
- uploads.push(arg);
117
- return {};
118
- });
119
- sinon.stub(this.deployer, "createBucket").resolves();
120
- yield this.deployer.putFolderOnBucket("plop", "./test/moddas");
121
- assert.strictEqual(uploads.length, 0);
122
- Contents[0].ETag = "plop";
123
- yield this.deployer.putFolderOnBucket("plop", "./test/moddas");
124
- assert.strictEqual(uploads.length, 1);
125
- uploads = [];
126
- Contents[0].ETag = '"312d05552187d3fdfdda3860fbeef48f"';
127
- Contents[0].Size = 123;
128
- yield this.deployer.putFolderOnBucket("plop", "./test/moddas");
129
- assert.strictEqual(uploads.length, 1);
60
+ async putFilesOnBucket() {
61
+ await this.deployer.putFilesOnBucket("plop", []);
62
+ await assert.rejects(
63
+ // @ts-ignore
64
+ () => this.deployer.putFilesOnBucket("plop", [{ key: "/test" }]), /Should have src and key defined/);
65
+ let Contents = [{ Key: "awsevents.js", Size: 527, ETag: '"ea1db4bb1545c62c50e6f0893e9f0992"' }];
66
+ let stub = sinon.stub().resolves({ Contents });
67
+ // Fake any uploads
68
+ let uploads = [];
69
+ mockClient(S3)
70
+ .on(ListObjectsV2Command)
71
+ .callsFake(stub)
72
+ .on(PutObjectCommand)
73
+ .callsFake(arg => {
74
+ uploads.push(arg);
75
+ return {};
130
76
  });
77
+ sinon.stub(this.deployer, "createBucket").resolves();
78
+ await this.deployer.putFolderOnBucket("plop", "./test/moddas");
79
+ assert.strictEqual(uploads.length, 0);
80
+ Contents[0].ETag = "plop";
81
+ await this.deployer.putFolderOnBucket("plop", "./test/moddas");
82
+ assert.strictEqual(uploads.length, 1);
83
+ uploads = [];
84
+ Contents[0].ETag = '"312d05552187d3fdfdda3860fbeef48f"';
85
+ Contents[0].Size = 123;
86
+ await this.deployer.putFolderOnBucket("plop", "./test/moddas");
87
+ assert.strictEqual(uploads.length, 1);
131
88
  }
132
- testGetPolicyDocument() {
133
- return __awaiter(this, void 0, void 0, function* () {
134
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_sts_1.STS).on(client_sts_1.GetCallerIdentityCommand).resolves({
135
- Account: "test"
136
- });
137
- try {
138
- // @ts-ignore
139
- this.manager.getWebda().getServices()["customservice"].getARNPolicy = () => {
140
- return [
141
- { Sid: "", Effect: "Allow", Action: [], Resource: "*" },
142
- { Sid: "", Effect: "Allow", Action: [], Resource: "*" }
143
- ];
144
- };
145
- let result = yield this.deployer.getPolicyDocument();
146
- assert.strictEqual(result.Statement.length, 4);
147
- }
148
- finally {
149
- mock.restore();
150
- }
89
+ async testGetPolicyDocument() {
90
+ const mock = mockClient(STS).on(GetCallerIdentityCommand).resolves({
91
+ Account: "test"
151
92
  });
93
+ try {
94
+ // @ts-ignore
95
+ this.manager.getWebda().getServices()["customservice"].getARNPolicy = () => {
96
+ return [
97
+ { Sid: "", Effect: "Allow", Action: [], Resource: "*" },
98
+ { Sid: "", Effect: "Allow", Action: [], Resource: "*" }
99
+ ];
100
+ };
101
+ let result = await this.deployer.getPolicyDocument();
102
+ assert.strictEqual(result.Statement.length, 4);
103
+ }
104
+ finally {
105
+ mock.restore();
106
+ }
152
107
  }
153
- testGetDefaultVpc() {
154
- return __awaiter(this, void 0, void 0, function* () {
155
- var vpcsSpy = sinon.stub().callsFake(() => __awaiter(this, void 0, void 0, function* () {
156
- if (vpcsSpy.callCount === 1) {
157
- return {
158
- Vpcs: []
159
- };
160
- }
108
+ async testGetDefaultVpc() {
109
+ var vpcsSpy = sinon.stub().callsFake(async () => {
110
+ if (vpcsSpy.callCount === 1) {
161
111
  return {
162
- Vpcs: [
163
- {
164
- VpcId: "vpc-667",
165
- IsDefault: false
166
- },
167
- {
168
- VpcId: "vpc-666",
169
- IsDefault: true
170
- }
171
- ]
112
+ Vpcs: []
172
113
  };
173
- }));
174
- var subnetsSpy = sinon.stub().callsFake(() => __awaiter(this, void 0, void 0, function* () {
175
- return {
176
- Subnets: [
177
- {
178
- SubnetId: "subnet-1"
179
- },
180
- {
181
- SubnetId: "subnet-2"
182
- }
183
- ]
184
- };
185
- }));
186
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_ec2_1.EC2)
187
- .on(client_ec2_1.DescribeVpcsCommand)
188
- .callsFake(vpcsSpy)
189
- .on(client_ec2_1.DescribeSubnetsCommand)
190
- .callsFake(subnetsSpy);
191
- try {
192
- let result = yield this.deployer.getDefaultVpc();
193
- assert.strictEqual(vpcsSpy.calledOnce, true);
194
- assert.strictEqual(subnetsSpy.notCalled, true);
195
- assert.strictEqual(result, undefined);
196
- core_1.CacheService.clearAllCache();
197
- result = yield this.deployer.getDefaultVpc();
198
- assert.deepStrictEqual(result, {
199
- Id: "vpc-666",
200
- Subnets: [{ SubnetId: "subnet-1" }, { SubnetId: "subnet-2" }]
201
- });
202
- assert.strictEqual(subnetsSpy.calledWith({
203
- Filters: [
204
- {
205
- Name: "vpc-id",
206
- Values: ["vpc-666"]
207
- }
208
- ]
209
- }), true);
210
- }
211
- finally {
212
- mock.restore();
213
114
  }
115
+ return {
116
+ Vpcs: [
117
+ {
118
+ VpcId: "vpc-667",
119
+ IsDefault: false
120
+ },
121
+ {
122
+ VpcId: "vpc-666",
123
+ IsDefault: true
124
+ }
125
+ ]
126
+ };
214
127
  });
215
- }
216
- testCommonPrefix() {
217
- return __awaiter(this, void 0, void 0, function* () {
218
- assert.strictEqual(this.deployer.commonPrefix("/test/bouzf", "/test/reffff"), "/test/");
219
- assert.strictEqual(this.deployer.commonPrefix("test/bouzf", "/test/reffff"), "");
220
- assert.strictEqual(this.deployer.commonPrefix("/tes", "/test/reffff"), "/tes");
221
- assert.strictEqual(this.deployer.commonPrefix("test/bouzf", "test/bouzf212"), "test/bouzf");
128
+ var subnetsSpy = sinon.stub().callsFake(async () => {
129
+ return {
130
+ Subnets: [
131
+ {
132
+ SubnetId: "subnet-1"
133
+ },
134
+ {
135
+ SubnetId: "subnet-2"
136
+ }
137
+ ]
138
+ };
222
139
  });
140
+ const mock = mockClient(EC2)
141
+ .on(DescribeVpcsCommand)
142
+ .callsFake(vpcsSpy)
143
+ .on(DescribeSubnetsCommand)
144
+ .callsFake(subnetsSpy);
145
+ try {
146
+ let result = await this.deployer.getDefaultVpc();
147
+ assert.strictEqual(vpcsSpy.calledOnce, true);
148
+ assert.strictEqual(subnetsSpy.notCalled, true);
149
+ assert.strictEqual(result, undefined);
150
+ CacheService.clearAllCache();
151
+ result = await this.deployer.getDefaultVpc();
152
+ assert.deepStrictEqual(result, {
153
+ Id: "vpc-666",
154
+ Subnets: [{ SubnetId: "subnet-1" }, { SubnetId: "subnet-2" }]
155
+ });
156
+ assert.strictEqual(subnetsSpy.calledWith({
157
+ Filters: [
158
+ {
159
+ Name: "vpc-id",
160
+ Values: ["vpc-666"]
161
+ }
162
+ ]
163
+ }), true);
164
+ }
165
+ finally {
166
+ mock.restore();
167
+ }
223
168
  }
224
- testCreateBucket() {
225
- return __awaiter(this, void 0, void 0, function* () {
226
- this.deployer.resources.Tags = this.deployer.transformMapTagsToArray({ test: "mytag" });
227
- var headSpy = sinon.stub();
228
- headSpy.callsFake(() => __awaiter(this, void 0, void 0, function* () {
229
- let res = {};
230
- switch (headSpy.callCount) {
231
- case 2:
232
- throw {
233
- name: "Forbidden"
234
- };
235
- case 3:
236
- throw new client_s3_1.NotFound({
237
- $metadata: {}
238
- });
239
- }
240
- return res;
241
- }));
242
- var createSpy = sinon.stub().resolves();
243
- var tagSpy = sinon.stub().resolves();
244
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_s3_1.S3)
245
- .on(client_s3_1.HeadBucketCommand)
246
- .callsFake(headSpy)
247
- .on(client_s3_1.CreateBucketCommand)
248
- .callsFake(createSpy)
249
- .on(client_s3_1.PutBucketTaggingCommand)
250
- .callsFake(tagSpy);
251
- try {
252
- yield this.deployer.createBucket("plop");
253
- // Bucket exists
254
- assert.strictEqual(headSpy.callCount, 1);
255
- assert.strictEqual(headSpy.calledWith({ Bucket: "plop" }), true);
256
- assert.strictEqual(createSpy.notCalled, true);
257
- assert.strictEqual(tagSpy.notCalled, true);
258
- // Bucket exists in another account or we do not have rights
259
- yield this.deployer.createBucket("plop");
260
- assert.strictEqual(headSpy.callCount, 2);
261
- assert.strictEqual(createSpy.notCalled, true);
262
- yield this.deployer.createBucket("plop");
263
- assert.strictEqual(headSpy.callCount, 3);
264
- assert.strictEqual(createSpy.calledOnce, true);
265
- assert.strictEqual(createSpy.calledWith({ Bucket: "plop" }), true);
266
- assert.strictEqual(tagSpy.calledOnce, true);
267
- assert.strictEqual(tagSpy.calledWith({ Bucket: "plop", Tagging: { TagSet: [{ Key: "test", Value: "mytag" }] } }), true);
268
- }
269
- finally {
270
- mock.restore();
169
+ async testCommonPrefix() {
170
+ assert.strictEqual(this.deployer.commonPrefix("/test/bouzf", "/test/reffff"), "/test/");
171
+ assert.strictEqual(this.deployer.commonPrefix("test/bouzf", "/test/reffff"), "");
172
+ assert.strictEqual(this.deployer.commonPrefix("/tes", "/test/reffff"), "/tes");
173
+ assert.strictEqual(this.deployer.commonPrefix("test/bouzf", "test/bouzf212"), "test/bouzf");
174
+ }
175
+ async testCreateBucket() {
176
+ this.deployer.resources.Tags = this.deployer.transformMapTagsToArray({ test: "mytag" });
177
+ var headSpy = sinon.stub();
178
+ headSpy.callsFake(async () => {
179
+ let res = {};
180
+ switch (headSpy.callCount) {
181
+ case 2:
182
+ throw {
183
+ name: "Forbidden"
184
+ };
185
+ case 3:
186
+ throw new NotFound({
187
+ $metadata: {}
188
+ });
271
189
  }
190
+ return res;
272
191
  });
192
+ var createSpy = sinon.stub().resolves();
193
+ var tagSpy = sinon.stub().resolves();
194
+ const mock = mockClient(S3)
195
+ .on(HeadBucketCommand)
196
+ .callsFake(headSpy)
197
+ .on(CreateBucketCommand)
198
+ .callsFake(createSpy)
199
+ .on(PutBucketTaggingCommand)
200
+ .callsFake(tagSpy);
201
+ try {
202
+ await this.deployer.createBucket("plop");
203
+ // Bucket exists
204
+ assert.strictEqual(headSpy.callCount, 1);
205
+ assert.strictEqual(headSpy.calledWith({ Bucket: "plop" }), true);
206
+ assert.strictEqual(createSpy.notCalled, true);
207
+ assert.strictEqual(tagSpy.notCalled, true);
208
+ // Bucket exists in another account or we do not have rights
209
+ await this.deployer.createBucket("plop");
210
+ assert.strictEqual(headSpy.callCount, 2);
211
+ assert.strictEqual(createSpy.notCalled, true);
212
+ await this.deployer.createBucket("plop");
213
+ assert.strictEqual(headSpy.callCount, 3);
214
+ assert.strictEqual(createSpy.calledOnce, true);
215
+ assert.strictEqual(createSpy.calledWith({ Bucket: "plop" }), true);
216
+ assert.strictEqual(tagSpy.calledOnce, true);
217
+ assert.strictEqual(tagSpy.calledWith({ Bucket: "plop", Tagging: { TagSet: [{ Key: "test", Value: "mytag" }] } }), true);
218
+ }
219
+ finally {
220
+ mock.restore();
221
+ }
273
222
  }
274
- testPutBucket() {
275
- return __awaiter(this, void 0, void 0, function* () {
276
- var putSpy = sinon.stub();
277
- var listSpy = sinon.stub();
278
- var createBucket = sinon.stub(this.deployer, "createBucket");
279
- createBucket.resolves();
280
- putSpy.resolves();
281
- listSpy.resolves({ Contents: [] });
282
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_s3_1.S3).on(client_s3_1.PutObjectCommand).callsFake(putSpy).on(client_s3_1.ListObjectsV2Command).callsFake(listSpy);
283
- try {
284
- // @ts-ignore shortcut to test both in one
285
- yield this.deployer.putFilesOnBucket("plop", [
286
- { src: __filename },
287
- { src: __dirname + "/index.ts", key: "plop.ts" },
288
- { key: "buffer.out", src: Buffer.from("bouzouf"), mimetype: "text/plain" }
289
- ]);
290
- assert.strictEqual(putSpy.callCount, 3);
291
- // checks call
292
- assert.strictEqual(putSpy.firstCall.firstArg.Body.constructor.name, "ReadStream");
293
- assert.strictEqual(putSpy.secondCall.firstArg.Body.constructor.name, "ReadStream");
294
- assert.deepStrictEqual(putSpy.thirdCall.firstArg.Body.constructor.name, "Buffer");
295
- assert.deepStrictEqual(putSpy.thirdCall.firstArg.Body.toString(), "bouzouf");
296
- assert.strictEqual(createBucket.calledOnce, true);
297
- // TODO Check upload optimization
223
+ async testPutBucket() {
224
+ var putSpy = sinon.stub();
225
+ var listSpy = sinon.stub();
226
+ var createBucket = sinon.stub(this.deployer, "createBucket");
227
+ createBucket.resolves();
228
+ putSpy.resolves();
229
+ listSpy.resolves({ Contents: [] });
230
+ const mock = mockClient(S3).on(PutObjectCommand).callsFake(putSpy).on(ListObjectsV2Command).callsFake(listSpy);
231
+ try {
232
+ // @ts-ignore shortcut to test both in one
233
+ await this.deployer.putFilesOnBucket("plop", [
234
+ { src: __filename },
235
+ { src: __dirname + "/index.ts", key: "plop.ts" },
236
+ { key: "buffer.out", src: Buffer.from("bouzouf"), mimetype: "text/plain" }
237
+ ]);
238
+ assert.strictEqual(putSpy.callCount, 3);
239
+ // checks call
240
+ assert.strictEqual(putSpy.firstCall.firstArg.Body.constructor.name, "ReadStream");
241
+ assert.strictEqual(putSpy.secondCall.firstArg.Body.constructor.name, "ReadStream");
242
+ assert.deepStrictEqual(putSpy.thirdCall.firstArg.Body.constructor.name, "Buffer");
243
+ assert.deepStrictEqual(putSpy.thirdCall.firstArg.Body.toString(), "bouzouf");
244
+ assert.strictEqual(createBucket.calledOnce, true);
245
+ // TODO Check upload optimization
246
+ }
247
+ finally {
248
+ mock.restore();
249
+ }
250
+ }
251
+ async testGetCertificate() {
252
+ var putSpy = sinon.stub();
253
+ var getZoneForDomainName = sinon.stub(this.deployer, "getZoneForDomainName");
254
+ var doCreateCertificate = sinon.stub(this.deployer, "doCreateCertificate");
255
+ getZoneForDomainName.callsFake(async () => {
256
+ if (getZoneForDomainName.callCount === 1) {
257
+ return undefined;
298
258
  }
299
- finally {
300
- mock.restore();
259
+ return { Id: "1234", HostedZone: "", Name: "", CallerReference: "" };
260
+ });
261
+ doCreateCertificate.resolves({ DomainName: "newlyCreated" });
262
+ putSpy.callsFake(async () => {
263
+ switch (putSpy.callCount) {
264
+ case 1:
265
+ return {
266
+ CertificateSummaryList: [
267
+ {
268
+ DomainName: "none.com"
269
+ }
270
+ ],
271
+ NextToken: "page2"
272
+ };
273
+ case 2:
274
+ return {
275
+ CertificateSummaryList: [
276
+ {
277
+ DomainName: "test.webda.io"
278
+ }
279
+ ]
280
+ };
281
+ default:
282
+ return { CertificateSummaryList: [] };
301
283
  }
302
284
  });
285
+ const mock = mockClient(ACM).on(ListCertificatesCommand).callsFake(putSpy);
286
+ try {
287
+ let certificate = await this.deployer.getCertificate("test.webda.io.");
288
+ assert.strictEqual(putSpy.calledTwice, true);
289
+ assert.strictEqual(doCreateCertificate.notCalled, true);
290
+ assert.strictEqual(getZoneForDomainName.notCalled, true);
291
+ assert.deepStrictEqual(certificate, { DomainName: "test.webda.io" });
292
+ await assert.rejects(async () => await this.deployer.getCertificate("test.webda.io"), /Cannot create certificate as Route53 Zone was not found/g);
293
+ assert.strictEqual(getZoneForDomainName.calledWith("test.webda.io"), true);
294
+ assert.strictEqual(doCreateCertificate.notCalled, true);
295
+ await this.deployer.getCertificate("test.webda.io", "us-east-1");
296
+ assert.strictEqual(doCreateCertificate.calledWith("test.webda.io", {
297
+ Id: "1234",
298
+ HostedZone: "",
299
+ Name: "",
300
+ CallerReference: ""
301
+ }), true);
302
+ }
303
+ finally {
304
+ mock.restore();
305
+ }
303
306
  }
304
- testGetCertificate() {
305
- return __awaiter(this, void 0, void 0, function* () {
306
- var putSpy = sinon.stub();
307
- var getZoneForDomainName = sinon.stub(this.deployer, "getZoneForDomainName");
308
- var doCreateCertificate = sinon.stub(this.deployer, "doCreateCertificate");
309
- getZoneForDomainName.callsFake(() => __awaiter(this, void 0, void 0, function* () {
310
- if (getZoneForDomainName.callCount === 1) {
311
- return undefined;
312
- }
313
- return { Id: "1234", HostedZone: "", Name: "", CallerReference: "" };
314
- }));
315
- doCreateCertificate.resolves({ DomainName: "newlyCreated" });
316
- putSpy.callsFake(() => __awaiter(this, void 0, void 0, function* () {
317
- switch (putSpy.callCount) {
318
- case 1:
319
- return {
320
- CertificateSummaryList: [
321
- {
322
- DomainName: "none.com"
323
- }
324
- ],
325
- NextToken: "page2"
326
- };
327
- case 2:
328
- return {
329
- CertificateSummaryList: [
330
- {
331
- DomainName: "test.webda.io"
332
- }
333
- ]
334
- };
335
- default:
336
- return { CertificateSummaryList: [] };
337
- }
338
- }));
339
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_acm_1.ACM).on(client_acm_1.ListCertificatesCommand).callsFake(putSpy);
340
- try {
341
- let certificate = yield this.deployer.getCertificate("test.webda.io.");
342
- assert.strictEqual(putSpy.calledTwice, true);
343
- assert.strictEqual(doCreateCertificate.notCalled, true);
344
- assert.strictEqual(getZoneForDomainName.notCalled, true);
345
- assert.deepStrictEqual(certificate, { DomainName: "test.webda.io" });
346
- yield assert.rejects(() => __awaiter(this, void 0, void 0, function* () { return yield this.deployer.getCertificate("test.webda.io"); }), /Cannot create certificate as Route53 Zone was not found/g);
347
- assert.strictEqual(getZoneForDomainName.calledWith("test.webda.io"), true);
348
- assert.strictEqual(doCreateCertificate.notCalled, true);
349
- yield this.deployer.getCertificate("test.webda.io", "us-east-1");
350
- assert.strictEqual(doCreateCertificate.calledWith("test.webda.io", {
351
- Id: "1234",
352
- HostedZone: "",
353
- Name: "",
354
- CallerReference: ""
355
- }), true);
356
- }
357
- finally {
358
- mock.restore();
307
+ async testGetZoneForDomainName() {
308
+ var callSpy = sinon.stub();
309
+ callSpy.callsFake(async () => {
310
+ switch (callSpy.callCount) {
311
+ case 1:
312
+ return { HostedZones: [], NextMarker: "plop" };
313
+ default:
314
+ return {
315
+ HostedZones: [
316
+ { Name: "webda.io." },
317
+ { Name: "bouzouf.io." },
318
+ { Name: "test2.test.webda.io." },
319
+ { Name: "test.webda.io." }
320
+ ]
321
+ };
359
322
  }
360
323
  });
324
+ const mock = mockClient(Route53).on(ListHostedZonesCommand).callsFake(callSpy);
325
+ try {
326
+ let result = await this.deployer.getZoneForDomainName("subdomain.test2.test.webda.io.");
327
+ assert.deepStrictEqual(result, {
328
+ Name: "test2.test.webda.io."
329
+ });
330
+ assert.strictEqual(callSpy.calledTwice, true);
331
+ result = await this.deployer.getZoneForDomainName("subdomain.webda.io");
332
+ assert.deepStrictEqual(result, {
333
+ Name: "webda.io."
334
+ });
335
+ result = await this.deployer.getZoneForDomainName("loopingz.com.");
336
+ assert.strictEqual(result, undefined);
337
+ }
338
+ finally {
339
+ mock.restore();
340
+ }
361
341
  }
362
- testGetZoneForDomainName() {
363
- return __awaiter(this, void 0, void 0, function* () {
364
- var callSpy = sinon.stub();
365
- callSpy.callsFake(() => __awaiter(this, void 0, void 0, function* () {
366
- switch (callSpy.callCount) {
342
+ async testDoCreateCertificate() {
343
+ var requestCertificate = sinon.stub();
344
+ var describeCertificate = sinon.stub();
345
+ var createDNSEntry = sinon.stub(this.deployer, "createDNSEntry");
346
+ var waitFor = sinon.stub(this.deployer, "waitFor");
347
+ createDNSEntry.callsFake(async () => { });
348
+ describeCertificate.resolves({});
349
+ const mock = mockClient(ACM)
350
+ .on(RequestCertificateCommand)
351
+ .callsFake(requestCertificate)
352
+ .on(DescribeCertificateCommand)
353
+ .callsFake(describeCertificate);
354
+ try {
355
+ waitFor.callsFake(async (callback) => {
356
+ switch (waitFor.callCount) {
367
357
  case 1:
368
- return { HostedZones: [], NextMarker: "plop" };
369
- default:
370
- return {
371
- HostedZones: [
372
- { Name: "webda.io." },
373
- { Name: "bouzouf.io." },
374
- { Name: "test2.test.webda.io." },
375
- { Name: "test.webda.io." }
376
- ]
377
- };
358
+ await callback();
359
+ case 2:
360
+ return new Promise(resolve => callback(resolve));
378
361
  }
379
- }));
380
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_route_53_1.Route53).on(client_route_53_1.ListHostedZonesCommand).callsFake(callSpy);
381
- try {
382
- let result = yield this.deployer.getZoneForDomainName("subdomain.test2.test.webda.io.");
383
- assert.deepStrictEqual(result, {
384
- Name: "test2.test.webda.io."
385
- });
386
- assert.strictEqual(callSpy.calledTwice, true);
387
- result = yield this.deployer.getZoneForDomainName("subdomain.webda.io");
388
- assert.deepStrictEqual(result, {
389
- Name: "webda.io."
390
- });
391
- result = yield this.deployer.getZoneForDomainName("loopingz.com.");
392
- assert.strictEqual(result, undefined);
393
- }
394
- finally {
395
- mock.restore();
396
- }
397
- });
398
- }
399
- testDoCreateCertificate() {
400
- return __awaiter(this, void 0, void 0, function* () {
401
- var requestCertificate = sinon.stub();
402
- var describeCertificate = sinon.stub();
403
- var createDNSEntry = sinon.stub(this.deployer, "createDNSEntry");
404
- var waitFor = sinon.stub(this.deployer, "waitFor");
405
- createDNSEntry.callsFake(() => __awaiter(this, void 0, void 0, function* () { }));
406
- describeCertificate.resolves({});
407
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_acm_1.ACM)
408
- .on(client_acm_1.RequestCertificateCommand)
409
- .callsFake(requestCertificate)
410
- .on(client_acm_1.DescribeCertificateCommand)
411
- .callsFake(describeCertificate);
412
- try {
413
- waitFor.callsFake((callback) => __awaiter(this, void 0, void 0, function* () {
414
- switch (waitFor.callCount) {
415
- case 1:
416
- yield callback();
417
- case 2:
418
- return new Promise(resolve => callback(resolve));
419
- }
420
- }));
421
- describeCertificate.callsFake(() => __awaiter(this, void 0, void 0, function* () {
422
- if (describeCertificate.callCount === 1) {
423
- return {
424
- Certificate: {
425
- DomainValidationOptions: [{}]
426
- }
427
- };
428
- }
429
- else {
362
+ });
363
+ describeCertificate.callsFake(async () => {
364
+ if (describeCertificate.callCount === 1) {
365
+ return {
366
+ Certificate: {
367
+ DomainValidationOptions: [{}]
368
+ }
369
+ };
370
+ }
371
+ else {
372
+ return {
373
+ Certificate: {
374
+ Status: "FAILED",
375
+ DomainValidationOptions: [{ ResourceRecord: "bouzouf" }]
376
+ }
377
+ };
378
+ }
379
+ });
380
+ requestCertificate.callsFake(async () => {
381
+ return { CertificateArn: "plop" };
382
+ });
383
+ await assert.rejects(async () => await this.deployer.doCreateCertificate("test.webda.io.", { Id: "1234" }), /Certificate validation has failed/g);
384
+ waitFor.callsFake(() => undefined);
385
+ await assert.rejects(async () => await this.deployer.doCreateCertificate("test.webda.io.", { Id: "1234" }), /Certificate validation has failed/g);
386
+ waitFor.resetHistory();
387
+ describeCertificate.resetHistory();
388
+ assert.strictEqual(createDNSEntry.notCalled, true);
389
+ // @ts-ignore
390
+ waitFor.callsFake(c => {
391
+ switch (waitFor.callCount) {
392
+ case 1:
430
393
  return {
431
- Certificate: {
432
- Status: "FAILED",
433
- DomainValidationOptions: [{ ResourceRecord: "bouzouf" }]
434
- }
394
+ Status: "PENDING_VALIDATION",
395
+ DomainValidationOptions: [{ ResourceRecord: { Value: "plop.com.", Name: "bouzouf.com" } }],
396
+ CertificateArn: "arn:plop"
435
397
  };
436
- }
437
- }));
438
- requestCertificate.callsFake(() => __awaiter(this, void 0, void 0, function* () {
439
- return { CertificateArn: "plop" };
440
- }));
441
- yield assert.rejects(() => __awaiter(this, void 0, void 0, function* () { return yield this.deployer.doCreateCertificate("test.webda.io.", { Id: "1234" }); }), /Certificate validation has failed/g);
442
- waitFor.callsFake(() => undefined);
443
- yield assert.rejects(() => __awaiter(this, void 0, void 0, function* () { return yield this.deployer.doCreateCertificate("test.webda.io.", { Id: "1234" }); }), /Certificate validation has failed/g);
444
- waitFor.resetHistory();
445
- describeCertificate.resetHistory();
446
- assert.strictEqual(createDNSEntry.notCalled, true);
447
- // @ts-ignore
448
- waitFor.callsFake(c => {
449
- switch (waitFor.callCount) {
450
- case 1:
451
- return {
452
- Status: "PENDING_VALIDATION",
453
- DomainValidationOptions: [{ ResourceRecord: { Value: "plop.com.", Name: "bouzouf.com" } }],
454
- CertificateArn: "arn:plop"
455
- };
456
- default:
457
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
458
- for (let i = 0; i < 5; i++) {
459
- if (yield c(resolve, reject)) {
460
- return;
461
- }
398
+ default:
399
+ return new Promise(async (resolve, reject) => {
400
+ for (let i = 0; i < 5; i++) {
401
+ if (await c(resolve, reject)) {
402
+ return;
462
403
  }
463
- reject("max");
464
- }));
465
- }
466
- });
467
- describeCertificate.callsFake(() => __awaiter(this, void 0, void 0, function* () {
468
- if (describeCertificate.callCount < 3) {
469
- return {
470
- Certificate: {
471
- Status: "PENDING_VALIDATION"
472
404
  }
473
- };
474
- }
475
- else {
476
- return {
477
- Certificate: {
478
- Status: "ISSUED"
479
- }
480
- };
481
- }
482
- }));
483
- yield this.deployer.doCreateCertificate("test.webda.io.", { Id: "1234", Name: "", CallerReference: "" });
484
- assert.strictEqual(createDNSEntry.calledWith("bouzouf.com", "CNAME", "plop.com.", { Id: "1234", Name: "", CallerReference: "" }), true);
485
- assert.strictEqual(describeCertificate.callCount, 3);
486
- waitFor.resetHistory();
487
- describeCertificate.resolves({ Certificate: { Status: "ERROR" } });
488
- let exception = false;
489
- try {
490
- // Should be able to use assert.rejects
491
- yield this.deployer.doCreateCertificate("test.webda.io.", { Id: "1234" });
405
+ reject("max");
406
+ });
492
407
  }
493
- catch (err) {
494
- assert.deepStrictEqual(err, { Status: "ERROR" });
495
- exception = true;
408
+ });
409
+ describeCertificate.callsFake(async () => {
410
+ if (describeCertificate.callCount < 3) {
411
+ return {
412
+ Certificate: {
413
+ Status: "PENDING_VALIDATION"
414
+ }
415
+ };
496
416
  }
497
- assert.strictEqual(exception, true);
498
- }
499
- finally {
500
- mock.restore();
501
- }
502
- });
503
- }
504
- testCreateDNSEntry() {
505
- return __awaiter(this, void 0, void 0, function* () {
506
- var callSpy = sinon.stub();
507
- var getZoneForDomainName = sinon.stub(this.deployer, "getZoneForDomainName");
508
- getZoneForDomainName.callsFake(() => __awaiter(this, void 0, void 0, function* () {
509
- if (getZoneForDomainName.callCount === 1) {
510
- return undefined;
417
+ else {
418
+ return {
419
+ Certificate: {
420
+ Status: "ISSUED"
421
+ }
422
+ };
511
423
  }
512
- return { Id: "1234", CallerReference: "", Name: "" };
513
- }));
514
- callSpy.resolves();
515
- const mock = (0, aws_sdk_client_mock_1.mockClient)(client_route_53_1.Route53).on(client_route_53_1.ChangeResourceRecordSetsCommand).callsFake(callSpy);
424
+ });
425
+ await this.deployer.doCreateCertificate("test.webda.io.", { Id: "1234", Name: "", CallerReference: "" });
426
+ assert.strictEqual(createDNSEntry.calledWith("bouzouf.com", "CNAME", "plop.com.", { Id: "1234", Name: "", CallerReference: "" }), true);
427
+ assert.strictEqual(describeCertificate.callCount, 3);
428
+ waitFor.resetHistory();
429
+ describeCertificate.resolves({ Certificate: { Status: "ERROR" } });
430
+ let exception = false;
516
431
  try {
517
- yield assert.rejects(() => __awaiter(this, void 0, void 0, function* () { return yield this.deployer.restrictedCall("createDNSEntry", "webda.io", "CNAME", "loopingz.com"); }), /Domain is not handled on AWS/g);
518
- assert.strictEqual(callSpy.notCalled, true);
519
- yield this.deployer.restrictedCall("createDNSEntry", "webda.io.", "CNAME", "loopingz.com");
520
- assert.strictEqual(callSpy.calledOnce, true);
521
- assert.deepStrictEqual(callSpy.firstCall.firstArg, {
522
- HostedZoneId: "1234",
523
- ChangeBatch: {
524
- Changes: [
525
- {
526
- Action: "UPSERT",
527
- ResourceRecordSet: {
528
- Name: "webda.io.",
529
- ResourceRecords: [
530
- {
531
- Value: "loopingz.com"
532
- }
533
- ],
534
- TTL: 360,
535
- Type: "CNAME"
536
- }
537
- }
538
- ],
539
- Comment: "webda-automated-deploiement"
540
- }
541
- });
432
+ // Should be able to use assert.rejects
433
+ await this.deployer.doCreateCertificate("test.webda.io.", { Id: "1234" });
542
434
  }
543
- finally {
544
- mock.restore();
435
+ catch (err) {
436
+ assert.deepStrictEqual(err, { Status: "ERROR" });
437
+ exception = true;
545
438
  }
546
- });
439
+ assert.strictEqual(exception, true);
440
+ }
441
+ finally {
442
+ mock.restore();
443
+ }
547
444
  }
548
- testHash() {
549
- return __awaiter(this, void 0, void 0, function* () {
550
- assert.strictEqual(yield this.deployer.restrictedCall("md5", "bouzouf"), "fc45f69f910da129848cd265448a5d00");
551
- assert.strictEqual(yield this.deployer.restrictedCall("hash", "bouzouf"), "fc45f69f910da129848cd265448a5d00");
552
- assert.strictEqual(yield this.deployer.restrictedCall("hash", "bouzouf", "md5", "base64"), "/EX2n5ENoSmEjNJlRIpdAA==");
553
- assert.strictEqual(yield this.deployer.restrictedCall("hash", "bouzouf", "sha256", "hex"), "af6773b1075007089c46a6d0b8e9ac03abfdb526de0683bfeb723f2448ea3f66");
445
+ async testCreateDNSEntry() {
446
+ var callSpy = sinon.stub();
447
+ var getZoneForDomainName = sinon.stub(this.deployer, "getZoneForDomainName");
448
+ getZoneForDomainName.callsFake(async () => {
449
+ if (getZoneForDomainName.callCount === 1) {
450
+ return undefined;
451
+ }
452
+ return { Id: "1234", CallerReference: "", Name: "" };
554
453
  });
454
+ callSpy.resolves();
455
+ const mock = mockClient(Route53).on(ChangeResourceRecordSetsCommand).callsFake(callSpy);
456
+ try {
457
+ await assert.rejects(async () => await this.deployer.restrictedCall("createDNSEntry", "webda.io", "CNAME", "loopingz.com"), /Domain is not handled on AWS/g);
458
+ assert.strictEqual(callSpy.notCalled, true);
459
+ await this.deployer.restrictedCall("createDNSEntry", "webda.io.", "CNAME", "loopingz.com");
460
+ assert.strictEqual(callSpy.calledOnce, true);
461
+ assert.deepStrictEqual(callSpy.firstCall.firstArg, {
462
+ HostedZoneId: "1234",
463
+ ChangeBatch: {
464
+ Changes: [
465
+ {
466
+ Action: "UPSERT",
467
+ ResourceRecordSet: {
468
+ Name: "webda.io.",
469
+ ResourceRecords: [
470
+ {
471
+ Value: "loopingz.com"
472
+ }
473
+ ],
474
+ TTL: 360,
475
+ Type: "CNAME"
476
+ }
477
+ }
478
+ ],
479
+ Comment: "webda-automated-deploiement"
480
+ }
481
+ });
482
+ }
483
+ finally {
484
+ mock.restore();
485
+ }
555
486
  }
556
- cov() {
557
- return __awaiter(this, void 0, void 0, function* () {
558
- assert.strictEqual(this.deployer.getRegion(), "us-east-1");
559
- this.deployer.waitFor((resolve) => __awaiter(this, void 0, void 0, function* () {
560
- resolve();
561
- return true;
562
- }), 1, "test", 1);
563
- this.deployer.resources.Tags = [{ Key: "plop", Value: "test" }];
564
- // @ts-ignore
565
- this.deployer.resources.Plop = { Tags: { plop2: "oké yep" } };
566
- assert.strictEqual(this.deployer.getDefaultTagsAsS3Tagging("Plop"), "plop2=ok%C3%A9%20yep&plop=test");
567
- });
487
+ async testHash() {
488
+ assert.strictEqual(await this.deployer.restrictedCall("md5", "bouzouf"), "fc45f69f910da129848cd265448a5d00");
489
+ assert.strictEqual(await this.deployer.restrictedCall("hash", "bouzouf"), "fc45f69f910da129848cd265448a5d00");
490
+ assert.strictEqual(await this.deployer.restrictedCall("hash", "bouzouf", "md5", "base64"), "/EX2n5ENoSmEjNJlRIpdAA==");
491
+ assert.strictEqual(await this.deployer.restrictedCall("hash", "bouzouf", "sha256", "hex"), "af6773b1075007089c46a6d0b8e9ac03abfdb526de0683bfeb723f2448ea3f66");
492
+ }
493
+ async cov() {
494
+ assert.strictEqual(this.deployer.getRegion(), "us-east-1");
495
+ this.deployer.waitFor(async (resolve) => {
496
+ resolve();
497
+ return true;
498
+ }, 1, "test", 1);
499
+ this.deployer.resources.Tags = [{ Key: "plop", Value: "test" }];
500
+ // @ts-ignore
501
+ this.deployer.resources.Plop = { Tags: { plop2: "oké yep" } };
502
+ assert.strictEqual(this.deployer.getDefaultTagsAsS3Tagging("Plop"), "plop2=ok%C3%A9%20yep&plop=test");
568
503
  }
569
504
  replaceForAWS() {
570
505
  assert.strictEqual(this.deployer._replaceForAWS("my/id"), "my_id");
@@ -578,51 +513,51 @@ let AWSDeployerTest = class AWSDeployerTest extends deployertest_1.DeployerTest
578
513
  }
579
514
  };
580
515
  __decorate([
581
- mocha_1.test
516
+ test
582
517
  ], AWSDeployerTest.prototype, "mapToArrayTags", null);
583
518
  __decorate([
584
- mocha_1.test
519
+ test
585
520
  ], AWSDeployerTest.prototype, "putFilesOnBucket", null);
586
521
  __decorate([
587
- mocha_1.test
522
+ test
588
523
  ], AWSDeployerTest.prototype, "testGetPolicyDocument", null);
589
524
  __decorate([
590
- mocha_1.test
525
+ test
591
526
  ], AWSDeployerTest.prototype, "testGetDefaultVpc", null);
592
527
  __decorate([
593
- mocha_1.test
528
+ test
594
529
  ], AWSDeployerTest.prototype, "testCommonPrefix", null);
595
530
  __decorate([
596
- mocha_1.test
531
+ test
597
532
  ], AWSDeployerTest.prototype, "testCreateBucket", null);
598
533
  __decorate([
599
- mocha_1.test
534
+ test
600
535
  ], AWSDeployerTest.prototype, "testPutBucket", null);
601
536
  __decorate([
602
- mocha_1.test
537
+ test
603
538
  ], AWSDeployerTest.prototype, "testGetCertificate", null);
604
539
  __decorate([
605
- mocha_1.test
540
+ test
606
541
  ], AWSDeployerTest.prototype, "testGetZoneForDomainName", null);
607
542
  __decorate([
608
- mocha_1.test
543
+ test
609
544
  ], AWSDeployerTest.prototype, "testDoCreateCertificate", null);
610
545
  __decorate([
611
- mocha_1.test
546
+ test
612
547
  ], AWSDeployerTest.prototype, "testCreateDNSEntry", null);
613
548
  __decorate([
614
- mocha_1.test
549
+ test
615
550
  ], AWSDeployerTest.prototype, "testHash", null);
616
551
  __decorate([
617
- mocha_1.test
552
+ test
618
553
  ], AWSDeployerTest.prototype, "cov", null);
619
554
  __decorate([
620
- mocha_1.test
555
+ test
621
556
  ], AWSDeployerTest.prototype, "replaceForAWS", null);
622
557
  __decorate([
623
- mocha_1.test
558
+ test
624
559
  ], AWSDeployerTest.prototype, "transformArrayTagsToMap", null);
625
560
  AWSDeployerTest = __decorate([
626
- mocha_1.suite
561
+ suite
627
562
  ], AWSDeployerTest);
628
563
  //# sourceMappingURL=index.spec.js.map