-
Notifications
You must be signed in to change notification settings - Fork 49
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
add list rule with service_group_id test #168
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -18,7 +18,8 @@ | |
|
||
const { readExternalSources } = require('ibm-cloud-sdk-core'); | ||
const { v4: uuidv4 } = require('uuid'); | ||
const ContextBasedRestrictionsV1 = require('../../dist/context-based-restrictions/v1'); | ||
// const ContextBasedRestrictionsV1 = require('../../dist/context-based-restrictions/v1'); | ||
const ContextBasedRestrictionsV1 = require('@ibm-cloud/platform-services/context-based-restrictions/v1'); | ||
|
||
const authHelper = require('../resources/auth-helper.js'); | ||
// const { doesNotReject } = require('assert'); | ||
|
@@ -580,6 +581,77 @@ describe('ContextBasedRestrictionsV1_integration', () => { | |
}); | ||
}); | ||
|
||
test('listRules() - List rule with valid service_group_id attribute', async () => { | ||
//create new rule with service_group_id attribute | ||
const ruleContextAttributeModel = { | ||
name: 'networkZoneId', | ||
value: 'af03b24cbaed353f53d2290a9123a54a', | ||
}; | ||
|
||
const ruleContextModel = { | ||
attributes: [ruleContextAttributeModel], | ||
}; | ||
|
||
const resourceAttributeAccountIdModel = { | ||
name: 'accountId', | ||
value: accountId, | ||
operator: 'stringEquals', | ||
}; | ||
|
||
const resourceAttributeServiceGroupIDModel = { | ||
name: 'service_group_id', | ||
value: 'IAM', | ||
}; | ||
|
||
const resourceModel = { | ||
attributes: [resourceAttributeAccountIdModel, resourceAttributeServiceGroupIDModel], | ||
}; | ||
|
||
const params = { | ||
contexts: [ruleContextModel], | ||
resources: [resourceModel], | ||
description: 'this is an example of rule with a service_group_id', | ||
enforcementMode: ContextBasedRestrictionsV1.CreateRuleConstants.EnforcementMode.ENABLED, | ||
transactionId: uuidv4(), | ||
}; | ||
|
||
let res; | ||
try { | ||
res = await contextBasedRestrictionsService.createRule(params); | ||
} catch (err) { | ||
console.warn(err); | ||
} | ||
|
||
expect(res).toBeDefined(); | ||
expect(res.status).toBe(201); | ||
expect(res.result).toBeDefined(); | ||
|
||
ruleId = res.result.id; | ||
ruleEtag = res.headers.etag; | ||
|
||
//list rule with service_group_id attribute | ||
const listParams = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect that we'd want to pass the serviceGroupId parameter to make sure filtering by the property is working as expected? |
||
accountId, | ||
transactionId: uuidv4(), | ||
}; | ||
|
||
const listRes = await contextBasedRestrictionsService.listRules(listParams); | ||
expect(listRes).toBeDefined(); | ||
expect(listRes.status).toBe(200); | ||
expect(listRes.result).toBeDefined(); | ||
padamstx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// cleanup | ||
const deleteParams = { | ||
ruleId: res.result.id, | ||
transactionId: uuidv4(), | ||
}; | ||
|
||
const deleteRes = await contextBasedRestrictionsService.deleteRule(deleteParams); | ||
expect(deleteRes).toBeDefined(); | ||
expect(deleteRes.status).toBe(204); | ||
expect(deleteRes.result).toBeDefined(); | ||
}); | ||
|
||
test('getRule() - Get the specified rule', async () => { | ||
const params = { | ||
ruleId, | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cam-d12 did you make this change or the generator code? The dist folder should have the latest locally built code. If you need to help with how to build the code into the dist folder, try the readme or reach out and I can try to help.