-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
We added a basic test during our [Hackergarten Meetup](https://www.meetup.com/de-DE/hackergarten-stuttgart/events/dvvlwsydcpbcb/).
- Loading branch information
Showing
2 changed files
with
316 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,53 @@ | ||
import { App, Stack } from "aws-cdk-lib"; | ||
import { Match, Template } from "aws-cdk-lib/assertions"; | ||
import { Secret } from "aws-cdk-lib/aws-secretsmanager"; | ||
import { Construct } from "constructs"; | ||
import { AuthOptions } from "../src/auth"; | ||
import { GithubCustomResource } from "../src/github-custom-resource"; | ||
|
||
describe("GithubCustomResource", () => { | ||
it("", () => {}); | ||
it("Should match snapshot", () => { | ||
// Given | ||
const app = new App(); | ||
const stack = new GithubCustomResourceTestStack(app, "GithubTestStack"); | ||
|
||
// When | ||
const template = Template.fromStack(stack); | ||
|
||
// Then | ||
expect(template).toMatchSnapshot(); | ||
}); | ||
|
||
it("Should contain GithubCustomResource with appAuth", () => { | ||
// Given | ||
const app = new App(); | ||
const stack = new GithubCustomResourceTestStack(app, "GithubTestStack"); | ||
|
||
// When | ||
const template = Template.fromStack(stack); | ||
|
||
// Then | ||
template.hasResourceProperties("AWS::SecretsManager::Secret", { Description: "GithubAppAuthSecret" }); | ||
template.hasResourceProperties("AWS::CloudFormation::CustomResource", { | ||
Auth: { | ||
secret: { | ||
Ref: Match.stringLikeRegexp("githubAuthSecret"), | ||
}, | ||
strategy: "auth-app", | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
class GithubCustomResourceTestStack extends Stack { | ||
constructor(scope: Construct, id: string) { | ||
super(scope, id); | ||
|
||
const secret = new Secret(this, "githubAuthSecret", { | ||
description: "GithubAppAuthSecret", | ||
}); | ||
new GithubCustomResource(this, "CR", { | ||
authOptions: AuthOptions.appAuth(secret), | ||
}); | ||
} | ||
} |