Skip to content

Commit

Permalink
fix typo and added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinZZ committed Jan 15, 2025
1 parent e2c7163 commit ded8610
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-iam/lib/oidc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class OpenIdConnectProvider extends Resource implements IOpenIdConnectPro
ClientIDList: props.clientIds,
ThumbprintList: props.thumbprints,
Url: props.url,
RejectUnauthoried: rejectUnauthorized,
RejectUnauthorized: rejectUnauthorized,

// code changes can cause thumbprint changes in case they weren't explicitly provided.
// add the code hash as a property so that CFN invokes the UPDATE handler in these cases,
Expand Down
23 changes: 23 additions & 0 deletions packages/aws-cdk-lib/aws-iam/test/oidc-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ describe('OpenIdConnectProvider resource', () => {
expect(stack.resolve(provider.openIdConnectProviderArn)).toStrictEqual({ Ref: 'MyProvider730BA1C8' });
});

it.each(
[true, false, undefined]
)('Check the status of RejectUnauthorized when IAM_OIDC_REJECT_UNAUTHORIZED_CONNECTIONS is set to different values', (flag) => {
// GIVEN
const app = new App({
context: {
'@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections': flag,
},
});
const stack = new Stack(app);

// WHEN
new iam.OpenIdConnectProvider(stack, 'MyProvider', {
url: 'https://my-issuer',
});

// THEN
Template.fromStack(stack).hasResourceProperties('Custom::AWSCDKOpenIdConnectProvider', {
Url: 'https://my-issuer',
RejectUnauthorized: flag ?? false,
});
});

test('static fromOpenIdConnectProviderArn can be used to import a provider', () => {
// GIVEN
const stack = new Stack();
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ When this feature flag is enabled, the default behaviour of OIDC Provider's cust
default to reject unauthorized connections when downloading CA Certificates.

When this feature flag is disabled, the behaviour will be the same as current and will allow downloading
thumbprints from unsecure connnections.
thumbprints from unsecure connections.


| Since | Default | Recommended |
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/cx-api/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ export const FLAGS: Record<string, FlagInfo> = {
default to reject unauthorized connections when downloading CA Certificates.
When this feature flag is disabled, the behaviour will be the same as current and will allow downloading
thumbprints from unsecure connnections.`,
thumbprints from unsecure connections.`,
introducedIn: { v2: 'V2NEXT' },
recommendedValue: true,
compatibilityWithOldBehaviorMd: 'Disable the feature flag to allow unsecure OIDC connection.',
Expand Down

0 comments on commit ded8610

Please sign in to comment.