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

test: clean up api key registration #12840

Merged
merged 1 commit into from
Dec 4, 2024
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
14 changes: 14 additions & 0 deletions packages/tests/src/scripts/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ async function main() {
}
}

console.log(`clean api key registration`);
const apiKeyRegistrationList =
await addStudioCleanService.getApiKeyRegistration();
if (apiKeyRegistrationList) {
for (const apiKey of apiKeyRegistrationList) {
try {
await addStudioCleanService.deleteApiKeyRegistration(apiKey?.id);
console.log(apiKey?.id, " is deleted");
} catch {
console.log(`Failed to delete api key ${apiKey?.id}`);
}
}
}

console.log(
`clean up the Azure resource group with name start with ${Project.namePrefix} (exclude ${excludePrefix})`
);
Expand Down
20 changes: 20 additions & 0 deletions packages/tests/src/utils/cleanHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,26 @@ export class AppStudioCleanHelper extends CleanHelper {
return response?.data?.access_token;
}

public async getApiKeyRegistration() {
const response = await this.execute(
"get",
`/api/v1.0/apiSecretRegistrations`
);
const results = response?.data?.value as any[];
// if (!results || results.length < 1) {
// throw new Error("Could not found apps in AppStudio.");
// }
return results;
}

public async deleteApiKeyRegistration(apiKeyId: string) {
await this.execute(
"delete",
`/api/v1.0/apiSecretRegistrations/${apiKeyId}`,
undefined
);
}

public async getAppsInAppStudio() {
const response = await this.execute("get", `/api/identityapps`);
const results = response?.data?.apps as any[];
Expand Down
Loading