-
Notifications
You must be signed in to change notification settings - Fork 44
fix(team): get team will fetch only from selected product #243
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
342ced5
fix(team): get team will fetch only from selected product
filiptubic 9b9a6eb
fix(team): add tests for fetching team by product
filiptubic 78ba04d
fix(team): fix lint error
filiptubic ef6f5ae
fix(team): add test before and after
filiptubic 5f9fe41
fix(team): add test before and after
filiptubic 2b803f2
fix(team): optimize test
filiptubic 50bffc2
fix(team): use product_filter but pass it to API
filiptubic 27b7a15
fix(team): add test for get all teams
filiptubic 9cc3d97
fix(team): fix lint error
filiptubic 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import os | ||
| import uuid | ||
| from expects import expect, equal | ||
| from mamba import before, description, it | ||
| from sdcclient import SdSecureClient, SdMonitorClient | ||
| from specs import be_successful_api_call | ||
| from collections import defaultdict | ||
|
|
||
| TEAM_PREFIX_NAME = 'sysdig-sdk - ' | ||
|
|
||
| with description("Teams", "integration", "teams") as self: | ||
| with before.all: | ||
| self.secure_client = SdSecureClient( | ||
| sdc_url=os.getenv("SDC_SECURE_URL", "https://secure.sysdig.com"), | ||
| token=os.getenv("SDC_SECURE_TOKEN") | ||
| ) | ||
| self.monitor_client = SdMonitorClient( | ||
| sdc_url=os.getenv("SDC_MONITOR_URL", "https://app.sysdigcloud.com"), | ||
| token=os.getenv("SDC_MONITOR_TOKEN") | ||
| ) | ||
|
|
||
| with before.each: | ||
| self.team_name = f'{TEAM_PREFIX_NAME}{uuid.uuid4()}' | ||
|
|
||
| with it("it should list all teams"): | ||
| ok, teams_monitor = self.monitor_client.get_teams() | ||
| expect((ok, teams_monitor)).to(be_successful_api_call) | ||
|
|
||
| ok, teams_secure = self.secure_client.get_teams() | ||
| expect((ok, teams_secure)).to(be_successful_api_call) | ||
|
|
||
| count_monitor = defaultdict(int) | ||
| count_secure = defaultdict(int) | ||
|
|
||
| def count_products(teams, count): | ||
| for team in teams: | ||
| for product in team['products']: | ||
| count[product] += 1 | ||
|
|
||
| count_products(teams_monitor, count_monitor) | ||
| count_products(teams_secure, count_secure) | ||
|
|
||
| expect(len(count_secure)).to(equal(len(count_monitor))) | ||
| for k, v in count_monitor.items(): | ||
| expect(count_secure[k]).to(equal(v)) | ||
| expect(len(teams_secure)).to(equal(len(teams_monitor))) | ||
|
|
||
| with it("it should list only monitor teams"): | ||
| ok, team = self.secure_client.create_team(self.team_name) | ||
| expect((ok, team)).to(be_successful_api_call) | ||
|
|
||
| ok, teams = self.monitor_client.get_teams(product_filter='SDC') | ||
| expect((ok, teams)).to(be_successful_api_call) | ||
|
|
||
| secure_teams = [t for t in teams if 'SDS' in t['products']] | ||
| expect(len(secure_teams)).to(equal(0)) | ||
|
|
||
| ok, res = self.secure_client.delete_team(self.team_name) | ||
| expect((ok, res)).to(be_successful_api_call) | ||
|
|
||
| with it("it should list only secure teams"): | ||
| ok, team = self.monitor_client.create_team(self.team_name) | ||
| expect((ok, team)).to(be_successful_api_call) | ||
|
|
||
| ok, teams = self.secure_client.get_teams(product_filter='SDS') | ||
| expect((ok, teams)).to(be_successful_api_call) | ||
|
|
||
| monitor_teams = [t for t in teams if 'SDC' in t['products']] | ||
| expect(len(monitor_teams)).to(equal(0)) | ||
|
|
||
| ok, res = self.monitor_client.delete_team(self.team_name) | ||
| expect((ok, res)).to(be_successful_api_call) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.