Skip to content

Commit

Permalink
Merge branch 'main' into s3-bucket-logging-policy-no-acl
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 28, 2022
2 parents 1023700 + 7c752db commit cdcb49a
Show file tree
Hide file tree
Showing 477 changed files with 17,804 additions and 2,208 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.v2.alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.57.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.56.1-alpha.0...v2.57.0-alpha.0) (2022-12-27)


### Bug Fixes

* **aws-redshift:** Columns are not dropped on removal from array ([#23011](https://github.com/aws/aws-cdk/issues/23011)) ([2981313](https://github.com/aws/aws-cdk/commit/298131312b513c0e73865e6fff74c189ee99e328)), closes [#22208](https://github.com/aws/aws-cdk/issues/22208)

## [2.56.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.56.0-alpha.0...v2.56.1-alpha.0) (2022-12-23)

## [2.56.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.55.1-alpha.0...v2.56.0-alpha.0) (2022-12-21)


### Features

* **integ-tests:** add serializedJson on match utility ([#23218](https://github.com/aws/aws-cdk/issues/23218)) ([1a62dc4](https://github.com/aws/aws-cdk/commit/1a62dc4590d725d3c03861af434a24789eaa0a2e))
* **servicecatalogappregistry:** Cross region warning and default application tag ([#23412](https://github.com/aws/aws-cdk/issues/23412)) ([8d359ae](https://github.com/aws/aws-cdk/commit/8d359ae35877ce066e419f7e2e7da2b0deb587e6))

## [2.55.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.55.0-alpha.0...v2.55.1-alpha.0) (2022-12-16)

## [2.55.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.54.0-alpha.0...v2.55.0-alpha.0) (2022-12-14)
Expand Down
45 changes: 45 additions & 0 deletions CHANGELOG.v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,51 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.57.0](https://github.com/aws/aws-cdk/compare/v2.56.1...v2.57.0) (2022-12-27)


### Features

* **cfnspec:** cloudformation spec v103.0.0 ([#23452](https://github.com/aws/aws-cdk/issues/23452)) ([e49e57d](https://github.com/aws/aws-cdk/commit/e49e57d3106f62c5d64c428cba73b4107d664cba))
* **lambda:** add support for auto-instrumentation with ADOT Lambda layer ([#23027](https://github.com/aws/aws-cdk/issues/23027)) ([fc70535](https://github.com/aws/aws-cdk/commit/fc70535fe699e72332d5ddb4543308e76a89594a))


### Bug Fixes

* **cfnspec:** v101.0.0 introduced specific types on several types that previously were typed as json ([#23448](https://github.com/aws/aws-cdk/issues/23448)) ([4fbc182](https://github.com/aws/aws-cdk/commit/4fbc1827b8978262da0b5b77b1ee9bc0ecfdcc3e))
* **codedeploy:** referenced Applications are not environment-aware ([#23405](https://github.com/aws/aws-cdk/issues/23405)) ([96242d7](https://github.com/aws/aws-cdk/commit/96242d73c0ae853524a567aece86f8a8a514495c))
* **s3:** buckets with SSE-KMS silently fail to receive logs ([#23385](https://github.com/aws/aws-cdk/issues/23385)) ([1b7a384](https://github.com/aws/aws-cdk/commit/1b7a384c330d168d64c0cd82118e5b5473d08a67))

## [2.56.1](https://github.com/aws/aws-cdk/compare/v2.56.0...v2.56.1) (2022-12-23)


### Bug Fixes

* **cfnspec:** v101.0.0 introduced specific types on several types that previously were typed as json ([#23448](https://github.com/aws/aws-cdk/issues/23448)) ([1b4e3a4](https://github.com/aws/aws-cdk/commit/1b4e3a4b503d5d08e976ccf245c20f4430bcba46))

## [2.56.0](https://github.com/aws/aws-cdk/compare/v2.55.1...v2.56.0) (2022-12-21)


### Features

* **aws-cognito:** add AuthSessionValidity property on a UserPoolClient ([#23040](https://github.com/aws/aws-cdk/issues/23040)) ([8896fb9](https://github.com/aws/aws-cdk/commit/8896fb902ad9c8d91a5ddb63df64963186bd09e1)), closes [#22854](https://github.com/aws/aws-cdk/issues/22854)
* **cfnspec:** cloudformation spec v102.0.0 ([#23372](https://github.com/aws/aws-cdk/issues/23372)) ([480b0a5](https://github.com/aws/aws-cdk/commit/480b0a5098e51248bbf36ebf2bcec57cc791c2b0))
* **core:** CfnResource dependency methods ([#23383](https://github.com/aws/aws-cdk/issues/23383)) ([ecedb00](https://github.com/aws/aws-cdk/commit/ecedb00ee3a3cfcaa2564a679fa635aff38f32d8)), closes [#20419](https://github.com/aws/aws-cdk/issues/20419) [#20418](https://github.com/aws/aws-cdk/issues/20418)
* **lambda:** expose all docker run options to container bundling of all lambda variants ([#23318](https://github.com/aws/aws-cdk/issues/23318)) ([02d0876](https://github.com/aws/aws-cdk/commit/02d0876bbb196e9fbeb32d977e7cf65229c8559d)), closes [#22829](https://github.com/aws/aws-cdk/issues/22829)
* **trigger:** Allow trigger to work with Lambda functions with long timeouts ([#23062](https://github.com/aws/aws-cdk/issues/23062)) ([9fd3811](https://github.com/aws/aws-cdk/commit/9fd3811b3213a227b84d79348e635a520fc537c7)), closes [#23058](https://github.com/aws/aws-cdk/issues/23058)


### Bug Fixes

* **apigateway:** allow multi-level base path mapping ([#23362](https://github.com/aws/aws-cdk/issues/23362)) ([86b6c6f](https://github.com/aws/aws-cdk/commit/86b6c6f796cbd15b7c53a4c0482a2b189d45300f)), closes [#23347](https://github.com/aws/aws-cdk/issues/23347)
* **autoscaling:** Allow adding AutoScalingGroup to multiple target groups ([#23044](https://github.com/aws/aws-cdk/issues/23044)) ([07acd18](https://github.com/aws/aws-cdk/commit/07acd180d778b7084d8519234cfc3570bb8846ba)), closes [/github.com/aws/aws-cdk/issues/5667#issuecomment-636657482](https://github.com/aws//github.com/aws/aws-cdk/issues/5667/issues/issuecomment-636657482) [#5667](https://github.com/aws/aws-cdk/issues/5667)
* **aws-eks:** fail to update both logging and access at the same time ([#22957](https://github.com/aws/aws-cdk/issues/22957)) ([606837d](https://github.com/aws/aws-cdk/commit/606837d3de5d048e3fb1674c30a3048e918f680a))
* **cognito:** quote or mime-encode `fromName` to comply RFC 5322 ([#23227](https://github.com/aws/aws-cdk/issues/23227)) ([78d474a](https://github.com/aws/aws-cdk/commit/78d474a12bce7805f88be96df926149c130bf513)), closes [#18903](https://github.com/aws/aws-cdk/issues/18903) [/www.rfc-editor.org/rfc/rfc5322#section-3](https://github.com/aws//www.rfc-editor.org/rfc/rfc5322/issues/section-3)
* **core:** cross region ssm writer update ([#23356](https://github.com/aws/aws-cdk/issues/23356)) ([87bd42d](https://github.com/aws/aws-cdk/commit/87bd42d41f11667aef673d9087c28cecedb87f66))
* **dynamodb:** add kms permissions to grantStreamRead ([#23400](https://github.com/aws/aws-cdk/issues/23400)) ([fcf1bfa](https://github.com/aws/aws-cdk/commit/fcf1bfaab173ee57bbf64d95be62bf10cbb1b851)), closes [40aws-cdk/aws-dynamodb/lib/table.ts#L1025-L1061](https://github.com/40aws-cdk/aws-dynamodb/lib/table.ts/issues/L1025-L1061)
* **s3-deployment:** source markers missing when there are multiple sources ([#23364](https://github.com/aws/aws-cdk/issues/23364)) ([8a7ec37](https://github.com/aws/aws-cdk/commit/8a7ec37e0085e952b59bebab1ecc880167a0691f)), closes [#23321](https://github.com/aws/aws-cdk/issues/23321) [40aws-cdk/aws-s3-deployment/lib/lambda/index.py#L64](https://github.com/40aws-cdk/aws-s3-deployment/lib/lambda/index.py/issues/L64) [40aws-cdk/aws-s3-deployment/lib/lambda/index.py#L137](https://github.com/40aws-cdk/aws-s3-deployment/lib/lambda/index.py/issues/L137)
* **timestream:** magneticStoreWriteProperties and retentionProperties not working as Json ([#23425](https://github.com/aws/aws-cdk/issues/23425)) ([b705224](https://github.com/aws/aws-cdk/commit/b7052242fb699ba89603ae718ae2d6b0ab9efa6f)), closes [#23404](https://github.com/aws/aws-cdk/issues/23404)

## [2.55.1](https://github.com/aws/aws-cdk/compare/v2.55.0...v2.55.1) (2022-12-16)


Expand Down
131 changes: 100 additions & 31 deletions packages/@aws-cdk/assertions/lib/match.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Matcher, MatchResult } from './matcher';
import { AbsentMatch } from './private/matchers/absent';
import { sortKeyComparator } from './private/sorting';
import { SparseMatrix } from './private/sparse-matrix';
import { getType } from './private/type';

/**
Expand Down Expand Up @@ -196,18 +198,53 @@ class ArrayMatch extends Matcher {
message: `Expected type array but received ${getType(actual)}`,
});
}
if (!this.subsequence && this.pattern.length !== actual.length) {
return new MatchResult(actual).recordFailure({

return this.subsequence ? this.testSubsequence(actual) : this.testFullArray(actual);
}

private testFullArray(actual: Array<any>): MatchResult {
const result = new MatchResult(actual);

let i = 0;
for (; i < this.pattern.length && i < actual.length; i++) {
const patternElement = this.pattern[i];
const matcher = Matcher.isMatcher(patternElement)
? patternElement
: new LiteralMatch(this.name, patternElement, { partialObjects: this.partialObjects });

const innerResult = matcher.test(actual[i]);
result.compose(`${i}`, innerResult);
}

if (i < this.pattern.length) {
result.recordFailure({
matcher: this,
path: [],
message: `Expected array of length ${this.pattern.length} but received ${actual.length}`,
message: `Not enough elements in array (expecting ${this.pattern.length}, got ${actual.length})`,
path: [`${i}`],
});
}
if (i < actual.length) {
result.recordFailure({
matcher: this,
message: `Too many elements in array (expecting ${this.pattern.length}, got ${actual.length})`,
path: [`${i}`],
});
}

return result;
}

private testSubsequence(actual: Array<any>): MatchResult {
const result = new MatchResult(actual);

// For subsequences, there is a lot of testing and backtracking that happens
// here, keep track of it all so we can report in a sensible amount of
// detail on what we did if the match happens to fail.

let patternIdx = 0;
let actualIdx = 0;
const matches = new SparseMatrix<MatchResult>();

const result = new MatchResult(actual);
while (patternIdx < this.pattern.length && actualIdx < actual.length) {
const patternElement = this.pattern[patternIdx];

Expand All @@ -216,30 +253,59 @@ class ArrayMatch extends Matcher {
: new LiteralMatch(this.name, patternElement, { partialObjects: this.partialObjects });

const matcherName = matcher.name;
if (this.subsequence && (matcherName == 'absent' || matcherName == 'anyValue')) {
if (matcherName == 'absent' || matcherName == 'anyValue') {
// array subsequence matcher is not compatible with anyValue() or absent() matcher. They don't make sense to be used together.
throw new Error(`The Matcher ${matcherName}() cannot be nested within arrayWith()`);
}

const innerResult = matcher.test(actual[actualIdx]);
matches.set(patternIdx, actualIdx, innerResult);

if (!this.subsequence || !innerResult.hasFailed()) {
result.compose(`[${actualIdx}]`, innerResult);
actualIdx++;
if (innerResult.isSuccess) {
result.compose(`${actualIdx}`, innerResult); // Record any captures
patternIdx++;
actualIdx++;
} else {
actualIdx++;
}
}

for (; patternIdx < this.pattern.length; patternIdx++) {
const pattern = this.pattern[patternIdx];
const element = (Matcher.isMatcher(pattern) || typeof pattern === 'object') ? ' ' : ` [${pattern}] `;
result.recordFailure({
matcher: this,
path: [],
message: `Missing element${element}at pattern index ${patternIdx}`,
});
// If we haven't matched all patterns:
// - Report on each one that did match on where it matched (perhaps it was wrong)
// - Report the closest match for the failing one
if (patternIdx < this.pattern.length) {
// Succeeded Pattern Index
for (let spi = 0; spi < patternIdx; spi++) {
const foundMatch = matches.row(spi).find(([, r]) => r.isSuccess);
if (!foundMatch) { continue; } // Should never fail but let's be defensive

const [index] = foundMatch;

result.compose(`${index}`, new MatchResult(actual[index]).recordFailure({
matcher: this,
message: `arrayWith pattern ${spi} matched here`,
path: [],
cost: 0, // This is an informational message so it would be unfair to assign it cost
}));
}

const failedMatches = matches.row(patternIdx);
failedMatches.sort(sortKeyComparator(([i, r]) => [r.failCost, i]));
if (failedMatches.length > 0) {
const [index, innerResult] = failedMatches[0];
result.recordFailure({
matcher: this,
message: `Could not match arrayWith pattern ${patternIdx}. This is the closest match`,
path: [`${index}`],
cost: 0, // Informational message
});
result.compose(`${index}`, innerResult);
} else {
// The previous matcher matched at the end of the pattern and we didn't even get to try anything
result.recordFailure({
matcher: this,
message: `Could not match arrayWith pattern ${patternIdx}. No more elements to try`,
path: [`${actual.length}`],
});
}
}

return result;
Expand Down Expand Up @@ -288,8 +354,8 @@ class ObjectMatch extends Matcher {
if (!(a in this.pattern)) {
result.recordFailure({
matcher: this,
path: [`/${a}`],
message: 'Unexpected key',
path: [a],
message: `Unexpected key ${a}`,
});
}
}
Expand All @@ -299,16 +365,16 @@ class ObjectMatch extends Matcher {
if (!(patternKey in actual) && !(patternVal instanceof AbsentMatch)) {
result.recordFailure({
matcher: this,
path: [`/${patternKey}`],
message: `Missing key '${patternKey}' among {${Object.keys(actual).join(',')}}`,
path: [patternKey],
message: `Missing key '${patternKey}'`,
});
continue;
}
const matcher = Matcher.isMatcher(patternVal) ?
patternVal :
new LiteralMatch(this.name, patternVal, { partialObjects: this.partial });
const inner = matcher.test(actual[patternKey]);
result.compose(`/${patternKey}`, inner);
result.compose(patternKey, inner);
}

return result;
Expand All @@ -324,35 +390,38 @@ class SerializedJson extends Matcher {
};

public test(actual: any): MatchResult {
const result = new MatchResult(actual);
if (getType(actual) !== 'string') {
result.recordFailure({
return new MatchResult(actual).recordFailure({
matcher: this,
path: [],
message: `Expected JSON as a string but found ${getType(actual)}`,
});
return result;
}
let parsed;
try {
parsed = JSON.parse(actual);
} catch (err) {
if (err instanceof SyntaxError) {
result.recordFailure({
return new MatchResult(actual).recordFailure({
matcher: this,
path: [],
message: `Invalid JSON string: ${actual}`,
});
return result;
} else {
throw err;
}
}

const matcher = Matcher.isMatcher(this.pattern) ? this.pattern : new LiteralMatch(this.name, this.pattern);
const innerResult = matcher.test(parsed);
result.compose(`(${this.name})`, innerResult);
return result;
if (innerResult.hasFailed()) {
innerResult.recordFailure({
matcher: this,
path: [],
message: 'Encoded JSON value does not match',
});
}
return innerResult;
}
}

Expand Down
Loading

0 comments on commit cdcb49a

Please sign in to comment.