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

feat(IAM Identity): add trusted profile identities api #212

Merged
merged 1 commit into from
Jun 9, 2023
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
163 changes: 162 additions & 1 deletion examples/iam-identity.v1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe('IamIdentityV1', () => {

let profileId = null;
let profileEtag = null;
let profileIdentitiesEtag = null;

let claimRuleId = null;
let claimRuleEtag = null;
Expand Down Expand Up @@ -825,7 +826,7 @@ describe('IamIdentityV1', () => {
// begin-create_link

const CreateProfileLinkRequestLink = {
crn: 'crn:v1:staging:public:iam-identity::a/18e3020749ce4744b0b472466d61fdb4::computeresource:Fake-Compute-Resource',
crn: `crn:v1:staging:public:iam-identity::a/${accountId}::computeresource:Fake-Compute-Resource`,
namespace: 'default',
name: 'nice name',
};
Expand Down Expand Up @@ -931,6 +932,166 @@ describe('IamIdentityV1', () => {

// end-delete_link
});
test('getProfileIdentities request example', async () => {

consoleLogMock.mockImplementation(output => {
originalLog(output);
});
consoleWarnMock.mockImplementation(output => {
originalWarn(output);
// when the test fails we need to print out the error message and stop execution right after it
expect(true).toBeFalsy();
});

originalLog('getProfileIdentities() result:');
// begin-get_profile_identities

const params = {
profileId,
};

try {
const res = await iamIdentityService.getProfileIdentities(params);
const { result } = res;
profileIdentitiesEtag = result.entity_tag;
console.log(JSON.stringify(res.result, null, 2));
} catch (err) {
console.warn(err);
}

// end-get_profile_identities

});
test('setProfileIdentities request example', async () => {

consoleLogMock.mockImplementation(output => {
originalLog(output);
});
consoleWarnMock.mockImplementation(output => {
originalWarn(output);
// when the test fails we need to print out the error message and stop execution right after it
expect(true).toBeFalsy();
});

originalLog('setProfileIdentities() result:');
// begin-set_profile_identities
const profileaccounts=[accountId];
const ProfileIdentity= {
identifier: iamId,
type: 'user',
accounts: profileaccounts,
description: 'identity description'
}
const profileIdentities= [ProfileIdentity]
const params = {
profileId: profileId,
identities: profileIdentities,
ifMatch: profileIdentitiesEtag
};

try {
const res = await iamIdentityService.setProfileIdentities(params);
console.log(JSON.stringify(res.result, null, 2));
} catch (err) {
console.warn(err);
}

// end-set_profile_identities
});
test('getProfileIdentity request example', async () => {

consoleLogMock.mockImplementation(output => {
originalLog(output);
});
consoleWarnMock.mockImplementation(output => {
originalWarn(output);
// when the test fails we need to print out the error message and stop execution right after it
expect(true).toBeFalsy();
});

originalLog('getProfileIdentity() result:');
// begin-get_profile_identity

const params = {
profileId: profileId,
identityType: 'user',
identifierId: iamId
};

try {
const res = await iamIdentityService.getProfileIdentity(params);
console.log(JSON.stringify(res.result, null, 2));
} catch (err) {
console.warn(err);
}

// end-get_profile_identity

});
test('setProfileIdentity request example', async () => {

consoleLogMock.mockImplementation(output => {
originalLog(output);
});
consoleWarnMock.mockImplementation(output => {
originalWarn(output);
// when the test fails we need to print out the error message and stop execution right after it
expect(true).toBeFalsy();
});

originalLog('setProfileIdentity() result:');
// begin-set_profile_identity

const profileaccounts=[accountId];
const params = {
profileId: profileId,
identityType: 'user',
identifier: iamIdMember,
type: 'user',
accounts: profileaccounts,
description: 'identity description'
};

try {
const res = await iamIdentityService.setProfileIdentity(params);
console.log(JSON.stringify(res.result, null, 2));
} catch (err) {
console.warn(err);
}

// end-set_profile_identity

});
test('deleteProfileIdentity request example', async () => {

consoleLogMock.mockImplementation(output => {
originalLog(output);
});
consoleWarnMock.mockImplementation(output => {
originalWarn(output);
// when the test fails we need to print out the error message and stop execution right after it
expect(true).toBeFalsy();
});

originalLog('deleteProfileIdentity() result:');
// begin-delete_profile_identity

const params = {
profileId: profileId,
identityType: 'user',
identifierId: iamIdMember
};

try {
const res = await iamIdentityService.deleteProfileIdentity(params);
console.log(JSON.stringify(res.result, null, 2));
} catch (err) {
console.warn(err);
}

// end-delete_profile_identity

});
test('deleteProfile request example', async () => {

consoleLogMock.mockImplementation(output => {
Expand Down
Loading