Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(integ-tests): add waiterProvider to IApiCall #27844

Merged
merged 14 commits into from
Dec 21, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ export interface IApiCall extends IConstruct {
*/
readonly provider: AssertionsProvider;

/**
* access the AssertionsProvider for the waiter state machine.
* This can be used to add additional IAM policies
* the the provider role policy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* access the AssertionsProvider for the waiter state machine.
* This can be used to add additional IAM policies
* the the provider role policy
* Access the AssertionsProvider for the waiter state machine.
* This can be used to add additional IAM policies
* to the provider role policy.

Can you please adjust the documentation for provider as well?

*
* @example
* declare const apiCall: AwsApiCall;
* apiCall.waiterProvider?.addToRolePolicy({
* Effect: 'Allow',
* Action: ['s3:GetObject'],
* Resource: ['*'],
* });
*/
readonly waiterProvider?: AssertionsProvider;

/**
* Returns the value of an attribute of the custom resource of an arbitrary
* type. Attributes are returned from the custom resource provider through the
Expand Down
13 changes: 0 additions & 13 deletions packages/@aws-cdk/integ-tests-alpha/lib/assertions/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ export interface AwsApiCallProps extends AwsApiCallOptions { }
export class AwsApiCall extends ApiCallBase {
public readonly provider: AssertionsProvider;

/**
* access the AssertionsProvider for the waiter state machine.
* This can be used to add additional IAM policies
* the the provider role policy
*
* @example
* declare const apiCall: AwsApiCall;
* apiCall.waiterProvider?.addToRolePolicy({
* Effect: 'Allow',
* Action: ['s3:GetObject'],
* Resource: ['*'],
* });
*/
public waiterProvider?: AssertionsProvider;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the build is failing here. Can't remove this docstring entirely since its a public API. Why was it removed in the first place?

Copy link
Contributor Author

@go-to-k go-to-k Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I added it anyway.

I've moved the same explanation to IApiCall, and at few lines up public readonly provider: AssertionsProvider; had no docstring, so I removed this too. Why is it good that there is no docstring there (provider)?

export class AwsApiCall extends ApiCallBase {
  public readonly provider: AssertionsProvider;

I looked aws.json(packages/@aws-cdk/integ-tests-alpha/awslint.json), but could not find the property.

Copy link
Contributor Author

@go-to-k go-to-k Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understood, that's because it's readonly.


protected readonly apiCallResource: CustomResource;
Expand Down
50 changes: 50 additions & 0 deletions packages/@aws-cdk/integ-tests-alpha/test/assertions/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,56 @@ describe('AwsApiCall', () => {
},
});
});
test('add policy to waiterProvider', () => {
// GIVEN
const app = new App();
const deplossert = new DeployAssert(app);

// WHEN
const apiCall = deplossert.awsApiCall('MyService', 'MyApi', {
param1: 'val1',
param2: 2,
}).expect(ExpectedResult.objectLike({
Key: 'Value',
})).waitForAssertions();
apiCall.waiterProvider?.addToRolePolicy({
Effect: 'Allow',
Action: ['s3:GetObject'],
Resource: ['*'],
});

// THEN
Template.fromStack(deplossert.scope).hasResourceProperties('AWS::IAM::Role', {
Policies: [
{
PolicyName: 'Inline',
PolicyDocument: {
Version: '2012-10-17',
Statement: [
{
Action: [
'myservice:MyApi',
],
Effect: 'Allow',
Resource: [
'*',
],
},
{
Action: [
's3:GetObject',
],
Effect: 'Allow',
Resource: [
'*',
],
},
],
},
},
],
});
});

describe('get attribute', () => {
test('getAttString', () => {
Expand Down
Loading