Skip to content

Commit

Permalink
test: fix lint errors in integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
padamstx committed Mar 11, 2021
1 parent 08fd1e2 commit d4b41f9
Showing 1 changed file with 78 additions and 77 deletions.
155 changes: 78 additions & 77 deletions test/integration/iam-identity.v1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,101 +629,102 @@ describe('IamIdentityV1_integration', () => {
});
});

function getPageTokenFromURL(urlstring) {
let pageToken = null;
if (urlstring) {
// We use a bogus "baseurl" in case "urlstring" is a relative url.
// This is fine since we're only trying to retrieve the "offset" query parameter.
const url = new URL(urlstring, 'https://fakehost.com');
pageToken = url.searchParams.get('pagetoken');
function getPageTokenFromURL(urlstring) {
let pageToken = null;
if (urlstring) {
// We use a bogus "baseurl" in case "urlstring" is a relative url.
// This is fine since we're only trying to retrieve the "offset" query parameter.
const url = new URL(urlstring, 'https://fakehost.com');
pageToken = url.searchParams.get('pagetoken');
}
return pageToken;
}
return pageToken;
}

async function getApiKeyById(apikeyId) {
let result = null;
try {
const params = {
id: apikeyId,
};
async function getApiKeyById(apikeyId) {
let result = null;
try {
const params = {
id: apikeyId,
};

const res = await iamIdentityService.getApiKey(params);
if (res != null) {
result = res.result;
const res = await iamIdentityService.getApiKey(params);
if (res != null) {
result = res.result;
}
return result;
} catch (err) {
return result;
}
return result;
} catch (err) {
return result;
}
}

async function getServiceId(serviceId) {
let result = null;
try {
const params = {
id: serviceId,
};
async function getServiceId(serviceId) {
let result = null;
try {
const params = {
id: serviceId,
};

const res = await iamIdentityService.getServiceId(params);
if (res != null) {
result = res.result;
const res = await iamIdentityService.getServiceId(params);
if (res != null) {
result = res.result;
}
return result;
} catch (err) {
return result;
}
return result;
} catch (err) {
return result;
}
}

async function cleanupResources() {
console.log('Cleaning resources...');
async function cleanupResources() {
console.log('Cleaning resources...');

try {
// list apikeys
const apikeyParams = {
accountId: accountId,
iamId: iamId,
pagesize: 100,
};
try {
// list apikeys
const apikeyParams = {
accountId: accountId,
iamId: iamId,
pagesize: 100,
};

const apikeyResponse = await iamIdentityService.listApiKeys(apikeyParams);
const apikeyResult = apikeyResponse.result;
if (apikeyResult.apikeys) {
for (const elem of apikeyResult.apikeys) {
if (elem.name == apikeyName) {
console.log('>>> Cleaning apikey: ', elem.id);
const params = {
id: elem.id,
};
const response = await iamIdentityService.deleteApiKey(params);
expect(response).not.toBeNull();
expect(response.status).toEqual(204);
}
}
}

const apikeyResponse = await iamIdentityService.listApiKeys(apikeyParams);
const apikeyResult = apikeyResponse.result;
if (apikeyResult.apikeys) {
for (const elem of apikeyResult.apikeys) {
if (elem.name == apikeyName) {
console.log('>>> Cleaning apikey: ', elem.id);
// list serviceIds
const serviceidParams = {
accountId: accountId,
name: serviceIdName,
pagesize: 100,
};

const serviceidResponse = await iamIdentityService.listServiceIds(serviceidParams);
const serviceidResult = serviceidResponse.result;
if (serviceidResult.serviceids) {
for (const elem of serviceidResult.serviceids) {
console.log('Cleaning serviceId: ', elem.id);
const params = {
id: elem.id,
};
const response = await iamIdentityService.deleteApiKey(params);
const response = await iamIdentityService.deleteServiceId(params);
expect(response).not.toBeNull();
expect(response.status).toEqual(204);
}
}
console.log('Finished cleaning resources!');
} catch (err) {
console.log(err);
throw err;
}

// list serviceIds
const serviceidParams = {
accountId: accountId,
name: serviceIdName,
pagesize: 100,
};

const serviceidResponse = await iamIdentityService.listServiceIds(serviceidParams);
const serviceidResult = serviceidResponse.result;
if (serviceidResult.serviceids) {
for (const elem of serviceidResult.serviceids) {
console.log('Cleaning serviceId: ', elem.id);
const params = {
id: elem.id,
};
const response = await iamIdentityService.deleteServiceId(params);
expect(response).not.toBeNull();
expect(response.status).toEqual(204);
}
}
console.log('Finished cleaning resources!');
} catch (err) {
console.log(err);
throw err;
}
}})
});

0 comments on commit d4b41f9

Please sign in to comment.