Skip to content

Commit

Permalink
Merge branch 'master' into feature-add-sse-header
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 26, 2021
2 parents d7df63d + 7e0c9a3 commit f6dbef1
Show file tree
Hide file tree
Showing 144 changed files with 3,942 additions and 278 deletions.
17 changes: 15 additions & 2 deletions packages/@aws-cdk/alexa-ask/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@

<!--END STABILITY BANNER-->

```ts
import * as alexaAsk from '@aws-cdk/alexa-ask';
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

```ts nofixture
import * as alexa_ask from '@aws-cdk/alexa-ask';
```

<!--BEGIN CFNONLY DISCLAIMER-->

There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.

For more information on the resources and properties available for this service, see the [CloudFormation documentation for Alexa::ASK](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Alexa_ASK.html).

(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) if you are interested in contributing to this construct library.)

<!--END CFNONLY DISCLAIMER-->
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert-internal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ The following matchers exist:
back to exact value matching.
- `arrayWith(E, [F, ...])` - value must be an array containing the given elements (or matchers) in any order.
- `stringLike(S)` - value must be a string matching `S`. `S` may contain `*` as wildcard to match any number
of characters.
of characters. Multiline strings are supported.
- `anything()` - matches any value.
- `notMatching(M)` - any value that does NOT match the given matcher (or exact value) given.
- `encodedJson(M)` - value must be a string which, when decoded as JSON, matches the given matcher or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ function isCallable(x: any): x is ((...args: any[]) => any) {
}

/**
* Do a glob-like pattern match (which only supports *s)
* Do a glob-like pattern match (which only supports *s). Supports multiline strings.
*/
export function stringLike(pattern: string): PropertyMatcher {
// Replace * with .* in the string, escape the rest and brace with ^...$
const regex = new RegExp(`^${pattern.split('*').map(escapeRegex).join('.*')}$`);
const regex = new RegExp(`^${pattern.split('*').map(escapeRegex).join('.*')}$`, 'm');

return annotateMatcher({ $stringContaining: pattern }, (value: any, failure: InspectionFailure) => {
if (typeof value !== 'string') {
Expand Down
36 changes: 35 additions & 1 deletion packages/@aws-cdk/assert-internal/test/have-resource.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { ABSENT, arrayWith, exactValue, expect as cdkExpect, haveResource, haveResourceLike, Capture, anything } from '../lib/index';
import {
ABSENT,
arrayWith,
exactValue,
expect as cdkExpect,
haveResource,
haveResourceLike,
Capture,
anything,
stringLike,
} from '../lib/index';
import { mkResource, mkStack } from './cloud-artifact';

test('support resource with no properties', () => {
Expand Down Expand Up @@ -156,6 +166,30 @@ describe('property absence', () => {
}).toThrowError(/Array did not contain expected element/);
});

test('can use matcher to test stringLike on single-line strings', () => {
const synthStack = mkResource({
Content: 'something required something',
});

expect(() => {
cdkExpect(synthStack).to(haveResource('Some::Resource', {
Content: stringLike('*required*'),
}));
}).not.toThrowError();
});

test('can use matcher to test stringLike on multi-line strings', () => {
const synthStack = mkResource({
Content: 'something\nrequired\nsomething',
});

expect(() => {
cdkExpect(synthStack).to(haveResource('Some::Resource', {
Content: stringLike('*required*'),
}));
}).not.toThrowError();
});

test('arrayContaining must match all elements in any order', () => {
const synthStack = mkResource({
List: ['a', 'b'],
Expand Down
93 changes: 36 additions & 57 deletions packages/@aws-cdk/assertions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The simplest assertion would be to assert that the template matches a given
template.

```ts
const expected = {
template.templateMatches({
Resources: {
BarLogicalId: {
Type: 'Foo::Bar',
Expand All @@ -46,9 +46,7 @@ const expected = {
},
},
},
};

template.templateMatches(expected);
});
```

By default, the `templateMatches()` API will use the an 'object-like' comparison,
Expand Down Expand Up @@ -84,23 +82,21 @@ The following code asserts that the `Properties` section of a resource of type
`Foo::Bar` contains the specified properties -

```ts
const expected = {
template.hasResourceProperties('Foo::Bar', {
Foo: 'Bar',
Baz: 5,
Qux: [ 'Waldo', 'Fred' ],
};
template.hasResourceProperties('Foo::Bar', expected);
});
```

Alternatively, if you would like to assert the entire resource definition, you
can use the `hasResource()` API.

```ts
const expected = {
template.hasResource('Foo::Bar', {
Properties: { Foo: 'Bar' },
DependsOn: [ 'Waldo', 'Fred' ],
};
template.hasResource('Foo::Bar', expected);
});
```

Beyond assertions, the module provides APIs to retrieve matching resources.
Expand Down Expand Up @@ -128,21 +124,17 @@ template.hasOutput('Foo', expected);
If you want to match against all Outputs in the template, use `*` as the `logicalId`.

```ts
const expected = {
template.hasOutput('*', {
Value: 'Bar',
Export: { Name: 'ExportBaz' },
};
template.hasOutput('*', expected);
});
```

`findOutputs()` will return a set of outputs that match the `logicalId` and `props`,
and you can use the `'*'` special case as well.

```ts
const expected = {
Value: 'Fred',
};
const result = template.findOutputs('*', expected);
const result = template.findOutputs('*', { Value: 'Fred' });
expect(result.Foo).toEqual({ Value: 'Fred', Description: 'FooFred' });
expect(result.Bar).toEqual({ Value: 'Fred', Description: 'BarFred' });
```
Expand Down Expand Up @@ -182,20 +174,18 @@ level, the list of keys in the target is a subset of the provided pattern.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Wobble: 'Flob',
}),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Brew: 'Coffee',
}),
}
template.hasResourceProperties('Foo::Bar', unexpected);
});
```

The `Match.objectEquals()` API can be used to assert a target as a deep exact
Expand Down Expand Up @@ -223,20 +213,18 @@ or outside of any matchers.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Bob: Match.absent(),
}),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Wobble: Match.absent(),
}),
};
template.hasResourceProperties('Foo::Bar', unexpected);
});
```

The `Match.anyValue()` matcher can be used to specify that a specific value should be found
Expand All @@ -261,20 +249,18 @@ This matcher can be combined with any of the other matchers.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: {
Wobble: [Match.anyValue(), "Flip"],
Wobble: [ Match.anyValue(), "Flip" ],
},
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = {
template.hasResourceProperties('Foo::Bar', {
Fred: {
Wimble: Match.anyValue(),
},
};
template.hasResourceProperties('Foo::Bar', unexpected);
});
```

### Array Matchers
Expand All @@ -297,16 +283,14 @@ This API will perform subset match on the target.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.arrayWith(['Flob']),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = Match.objectLike({
template.hasResourceProperties('Foo::Bar', Match.objectLike({
Fred: Match.arrayWith(['Wobble']),
});
template.hasResourceProperties('Foo::Bar', unexpected);
}));
```

*Note:* The list of items in the pattern array should be in order as they appear in the
Expand Down Expand Up @@ -334,16 +318,14 @@ not match the pattern specified.
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: Match.not(['Flob']),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = Match.objectLike({
template.hasResourceProperties('Foo::Bar', Match.objectLike({
Fred: Match.not(['Flob', 'Cat']),
});
template.hasResourceProperties('Foo::Bar', unexpected);
}));
```

### Serialized JSON
Expand All @@ -370,20 +352,18 @@ The `Match.serializedJson()` matcher allows deep matching within a stringified J
// }

// The following will NOT throw an assertion error
const expected = {
template.hasResourceProperties('Foo::Bar', {
Baz: Match.serializedJson({
Fred: Match.arrayWith(["Waldo"]),
}),
};
template.hasResourceProperties('Foo::Bar', expected);
});

// The following will throw an assertion error
const unexpected = {
template.hasResourceProperties('Foo::Bar', {
Baz: Match.serializedJson({
Fred: ["Waldo", "Johnny"],
}),
};
template.hasResourceProperties('Foo::Bar', unexpected);
});
```

[Pipeline BuildSpec]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html#cfn-codebuild-project-source-buildspec
Expand Down Expand Up @@ -411,11 +391,10 @@ matching resource.

const fredCapture = new Capture();
const waldoCapture = new Capture();
const expected = {
template.hasResourceProperties('Foo::Bar', {
Fred: fredCapture,
Waldo: ["Qix", waldoCapture],
}
template.hasResourceProperties('Foo::Bar', expected);
});

fredCapture.asArray(); // returns ["Flob", "Cat"]
waldoCapture.asString(); // returns "Qux"
Expand Down
13 changes: 12 additions & 1 deletion packages/@aws-cdk/aws-accessanalyzer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@

This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

```ts
```ts nofixture
import * as accessanalyzer from '@aws-cdk/aws-accessanalyzer';
```

<!--BEGIN CFNONLY DISCLAIMER-->

There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.

For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::AccessAnalyzer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_AccessAnalyzer.html).

(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) if you are interested in contributing to this construct library.)

<!--END CFNONLY DISCLAIMER-->
15 changes: 14 additions & 1 deletion packages/@aws-cdk/aws-amazonmq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@

<!--END STABILITY BANNER-->

```ts
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

```ts nofixture
import * as amazonmq from '@aws-cdk/aws-amazonmq';
```

<!--BEGIN CFNONLY DISCLAIMER-->

There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.

For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::AmazonMQ](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_AmazonMQ.html).

(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) if you are interested in contributing to this construct library.)

<!--END CFNONLY DISCLAIMER-->
Loading

0 comments on commit f6dbef1

Please sign in to comment.