Skip to content

fix(e2e): delete cognitoidentity resources in After call #3955

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

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion features/cognitoidentity/cognitoidentity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Feature:
Given I create a Cognito identity pool with prefix "awssdkjs"
And I describe the Cognito identity pool ID
Then the status code should be 200
And I delete the Cognito identity pool

Scenario: Error handling
Given I create a Cognito identity pool with prefix ""
Expand Down
34 changes: 19 additions & 15 deletions features/cognitoidentity/step_definitions/cognitoidentity.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
const { Before, Given, Then } = require("@cucumber/cucumber");
const { After, Before, Given } = require("@cucumber/cucumber");

Before({ tags: "@cognitoidentity" }, function (scenario, callback) {
Before({ tags: "@cognitoidentity" }, function () {
const { CognitoIdentity } = require("../../../clients/client-cognito-identity");
this.service = new CognitoIdentity({});
callback();
});

Given("I create a Cognito identity pool with prefix {string}", function (prefix, callback) {
const expectError = prefix === "" ? false : undefined;
const params = {
IdentityPoolName: this.uniqueName(prefix, ""),
AllowUnauthenticatedIdentities: true,
};
this.request(null, "createIdentityPool", params, callback, expectError);
After({ tags: "@cognitoidentity" }, async function () {
if (this.identityPoolId) {
this.service.deleteIdentityPool({ IdentityPoolId: this.identityPoolId });
this.identityPoolId = undefined;
}
});

Given("I describe the Cognito identity pool ID", function (callback) {
this.identityPoolId = this.data.IdentityPoolId;
this.request(null, "describeIdentityPool", { IdentityPoolId: this.data.IdentityPoolId }, callback);
Given("I create a Cognito identity pool with prefix {string}", async function (prefix) {
try {
this.data = await this.service.createIdentityPool({
IdentityPoolName: this.uniqueName(prefix),
AllowUnauthenticatedIdentities: true,
});
this.identityPoolId = this.data.IdentityPoolId;
} catch (error) {
this.error = error;
}
});

Then("I delete the Cognito identity pool", function (callback) {
this.request(null, "deleteIdentityPool", { IdentityPoolId: this.identityPoolId }, callback);
Given("I describe the Cognito identity pool ID", async function () {
this.data = await this.service.describeIdentityPool({ IdentityPoolId: this.identityPoolId });
});