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

{Role} Bump role_definitions API version to 2022-05-01-preview #26577

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def default_api_version(self):
ResourceType.MGMT_KEYVAULT: '2023-02-01',
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2022-04-01', {
'classic_administrators': '2015-06-01',
'role_definitions': '2022-04-01',
'role_definitions': '2022-05-01-preview',
'provider_operations_metadata': '2018-01-01-preview'
}),
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2022-02-01-preview', {
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from azure.cli.testsdk import MSGraphNameReplacer
from ..util import MSGraphUpnReplacer
from azure.cli.testsdk import ScenarioTest
from azure.cli.testsdk import ScenarioTest, LiveScenarioTest
from azure.cli.testsdk.scenario_tests import AllowLargeResponse


Expand Down Expand Up @@ -768,9 +768,6 @@ def test_user_scenario(self):
self.cmd('ad user get-member-groups --id {user1_id}',
checks=self.check('[0].displayName', self.kwargs['group']))

# list
self.cmd('ad user list')

# delete
self.cmd('ad user delete --id {user1_id}')

Expand Down Expand Up @@ -994,6 +991,13 @@ def test_special_characters_in_upn(self):
self.cmd('ad user delete --id {upn}')


class GraphLiveScenarioTest(LiveScenarioTest):
# Only test list commands in live mode to avoid recording tenant information

def test_user_list(self):
self.cmd('ad user list')


def _get_id_from_value(permissions, value):
"""Get id from value for appRoles or oauth2PermissionScopes."""
# https://docs.microsoft.com/en-us/graph/api/resources/serviceprincipal?view=graph-rest-1.0#properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def test_role_definition_scenario(self):
class RoleAssignmentScenarioTest(RoleScenarioTestBase):

def __init__(self, *arg, **kwargs):
super().__init__(*arg, random_config_dir=True, **kwargs)
super().__init__(*arg, **kwargs)
Copy link
Member Author

@jiasli jiasli Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random_config_dir=True needs to be removed according to #26577 (comment)

@bebound, should I revert it? If not, playback test may fail. If yes, live test will certainly fail, so other team member can't live run role module's tests.

I can also temporarily disable test_role_assignment_handle_conflicted_assignments to eliminate the root cause which writes to config file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preferred solution is to merge #26475.
This is a good chance to test it works. It only affect test, even if it contains bugs, it will not affect user.


@ResourceGroupPreparer(name_prefix='cli_role_assign')
@AllowLargeResponse()
Expand Down Expand Up @@ -315,14 +315,6 @@ def test_role_assignment_scenario(self, resource_group):
self.check("length([])", 2)
])

# test couple of more general filters
result = self.cmd('role assignment list -g {rg} --include-inherited').get_output_in_json()
# There are role assignments inherited from subscription, so we can't tell the exact number
self.assertTrue(len(result) >= 1)

result = self.cmd('role assignment list --all').get_output_in_json()
self.assertTrue(len(result) >= 1)

self.cmd('role assignment delete --assignee {group_id} --role {role} -g {rg}')
self.cmd('role assignment delete --assignee {upn} --role {role} -g {rg}')
self.cmd('role assignment list -g {rg}',
Expand Down Expand Up @@ -686,16 +678,28 @@ def check_changelogs():
finally:
self.cmd('ad user delete --id {upn}')


class RoleAssignmentLiveScenarioTest(LiveScenarioTest):
# Only test list commands in live mode to avoid recording tenant information

@ResourceGroupPreparer(name_prefix='cli_role_assign')
def test_role_assignment_list(self, resource_group):
# List all role assignments under a subscription
self.cmd('role assignment list --all', checks=[self.greater_than("length([])", 0)])

# List role assignments for a resource group.
self.cmd('role assignment list -g {rg}', checks=[self.check("length([])", 0)])

# There are role assignments inherited from subscription, so we can't tell the exact number.
self.cmd('role assignment list -g {rg} --include-inherited', checks=[self.greater_than("length([])", 0)])

@ResourceGroupPreparer(name_prefix='cli_test_assignments_for_coadmins')
@AllowLargeResponse()
def test_role_assignment_for_co_admins(self, resource_group):

result = self.cmd('role assignment list --include-classic-administrator').get_output_in_json()
self.assertTrue([x for x in result if x['roleDefinitionName'] in ['CoAdministrator', 'AccountAdministrator']])
self.cmd('role assignment list -g {}'.format(resource_group), checks=[
self.check("length([])", 0)
])
result = self.cmd('role assignment list -g {} --include-classic-administrator'.format(resource_group)).get_output_in_json()

result = self.cmd('role assignment list -g {rg} --include-classic-administrator').get_output_in_json()
self.assertTrue([x for x in result if x['roleDefinitionName'] in ['CoAdministrator', 'AccountAdministrator']])


Expand Down
Loading