Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
da53d7a
remove two deprecated kinds 'webapp' 'registration', and add 'azurebo…
jiaxuwu2021 May 7, 2022
560cab2
fix test case
chinazhangchao Jun 10, 2022
f1476e9
Merge branch 'dev' into jiaxuwu/clibotcreateazurebot
chinazhangchao Jun 10, 2022
f4fb67b
Merge branch 'jiaxuwu/clibotcreateazurebot' into chao/clibotcreate
chinazhangchao Jun 10, 2022
34dc78c
add app_type param, upgrade azure-mgmt-botservice
chinazhangchao Jun 14, 2022
7e212fb
Merge branch 'dev' into chao/clibotcreate
chinazhangchao Jun 14, 2022
fafca0d
add param
chinazhangchao Jun 15, 2022
217803e
Merge branch 'dev' into chao/clibotcreate
chinazhangchao Jun 17, 2022
c54a44f
fix test case
chinazhangchao Jun 17, 2022
67091e9
fix test error
chinazhangchao Jun 17, 2022
39798b5
fix test case
chinazhangchao Jun 17, 2022
f4de72b
fix test case
chinazhangchao Jun 20, 2022
6dc39d4
Merge branch 'dev' of https://github.com/Azure/azure-cli into chao/cl…
chinazhangchao Jun 20, 2022
e29ce63
fix test case
chinazhangchao Jun 20, 2022
954afd3
fix test case
chinazhangchao Jun 20, 2022
e05d898
fix test case
chinazhangchao Jun 20, 2022
f971fab
fix test case
chinazhangchao Jun 21, 2022
371c07b
Merge branch 'dev' of https://github.com/Azure/azure-cli into chao/cl…
chinazhangchao Jun 21, 2022
e574433
fix
chinazhangchao Jun 21, 2022
64c1bdc
fix tests. update recoding
fangyangci Jun 22, 2022
ab8e772
update recording
chinazhangchao Jun 24, 2022
0d8bcd0
update recording
chinazhangchao Jun 24, 2022
e0dad96
Merge branch 'dev' of https://github.com/Azure/azure-cli into chao/cl…
chinazhangchao Jun 24, 2022
581c316
fix errorexception
chinazhangchao Jun 24, 2022
7355aee
Merge branch 'dev' of https://github.com/Azure/azure-cli into chao/cl…
chinazhangchao Jun 24, 2022
d3dc2ae
update recording
chinazhangchao Jun 24, 2022
a73ac49
add bot type test
chinazhangchao Jun 27, 2022
8fd5ff6
Merge branch 'dev' of https://github.com/Azure/azure-cli into chao/cl…
chinazhangchao Jun 27, 2022
f00d005
change azure-mgmt-botservice version
chinazhangchao Jun 27, 2022
83f9e15
use new error types
chinazhangchao Jun 27, 2022
637fdd8
change import
chinazhangchao Jun 27, 2022
0117a2c
format
chinazhangchao Jun 27, 2022
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
Prev Previous commit
Next Next commit
fix test case
  • Loading branch information
chinazhangchao committed Jun 10, 2022
commit 560cab254b438ada4eca110a0152589aa1665cc1
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __handle_failed_name_check(name_response, cmd, client, resource_group_name,
raise e


def create(cmd, client, resource_group_name, resource_name, msa_app_id, description=None, display_name=None,
def create(cmd, client, resource_group_name, resource_name, msa_app_id, app_type, description=None, display_name=None,
endpoint=None, tags=None, location='global', sku_name='F0', cmek_key_vault_url=None):
# Kind only support azure bot for now
kind = "azurebot"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def test_botservice_registration_bot_create(self, resource_group):
})

self.cmd(
'az bot create -k registration -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id} -p '
'{password} --tags key1=value1',
'az bot create -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id} '
'--tags key1=value1',
checks=[
self.check('name', '{botname}'),
self.check('properties.description', '{description}'),
Expand Down Expand Up @@ -142,8 +142,8 @@ def test_botservice_registration_bot_create_specific_location(self, resource_gro
})

self.cmd(
'az bot create -k registration -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id} -p '
'{password} --tags key1=value1 -l {location}',
'az bot create -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id} '
'--tags key1=value1 -l {location}',
checks=[
self.check('name', '{botname}'),
self.check('properties.description', '{description}'),
Expand Down Expand Up @@ -174,8 +174,8 @@ def test_botservice_create_should_be_idempotent_and_return_existing_bot_info(sel
})

self.cmd(
'az bot create -k registration -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id} -p '
'{password} --tags key1=value1',
'az bot create -g {rg} -n {botname} -d {description} -e {endpoint} --app-type MultiTenant --appid {app_id} '
'--tags key1=value1',
checks=[
self.check('name', '{botname}'),
self.check('properties.description', '{description}'),
Expand All @@ -185,8 +185,8 @@ def test_botservice_create_should_be_idempotent_and_return_existing_bot_info(sel
])

self.cmd(
'az bot create -k registration -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id} -p '
'{password} --tags key1=value1',
'az bot create -g {rg} -n {botname} -d {description} -e {endpoint} --app-type MultiTenant --appid {app_id} '
'--tags key1=value1',
checks=[
self.check('name', '{botname}'),
self.check('properties.description', '{description}'),
Expand Down Expand Up @@ -215,7 +215,7 @@ def test_botservice_create_v4_csharp_echo_webapp_bot(self, resource_group):
shutil.rmtree(dir_path)

self.cmd(
'az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Csharp --echo',
'az bot create -g {rg} -n {botname} --appid {app_id}',
checks=[
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -259,7 +259,7 @@ def test_botservice_create_v4_js_echo_webapp_bot(self, resource_group):
# clean up the folder
shutil.rmtree(dir_path)

self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Javascript --echo',
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id} ',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -290,7 +290,7 @@ def test_botservice_create_v4_js_empty_webapp_for_webapp_bot(self, resource_grou
'password': str(uuid.uuid4())
})
self.cmd(
'az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Javascript')
'az bot create -g {rg} -n {botname} --appid {app_id} ')

@ResourceGroupPreparer(random_name_length=20)
@live_only() # if the path to download already exist the tests fail as by design which makes this not idempotent
Expand All @@ -310,8 +310,7 @@ def test_botservice_download_should_create_appsettings_for_v4_csharp_webapp_echo
# clean up the folder
shutil.rmtree(dir_path)

results = self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Csharp '
'--echo',
results = self.cmd('az bot create -g {rg} -n {botname} --appid {app_id} ',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -352,7 +351,7 @@ def test_botservice_download_should_create_env_file_for_v4_node_webapp_echo_bots
shutil.rmtree(dir_path)

self.cmd(
'az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Javascript --echo',
'az bot create -g {rg} -n {botname} --appid {app_id} ',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -391,7 +390,7 @@ def test_botservice_keep_node_modules_should_not_empty_node_modules_or_install_d
# clean up the folder
shutil.rmtree(dir_path)

self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Javascript --echo',
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id} ',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -423,7 +422,7 @@ def test_botservice_create_should_create_registration_bot_without_endpoint(self,
# Delete the bot if already exists
self.cmd('az bot delete -g {rg} -n {botname}')

self.cmd('az bot create -k registration -g {rg} -n {botname} --appid {app_id}')
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id}')

@ResourceGroupPreparer(random_name_length=20)
def test_create_v4_webapp_bot_should_succeed_with_ending_hyphen(self, resource_group):
Expand All @@ -445,7 +444,7 @@ def test_create_v4_webapp_bot_should_succeed_with_ending_hyphen(self, resource_g
# Clean up the folder
shutil.rmtree(dir_path)

self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Csharp',
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id} ',
checks=[
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand All @@ -469,7 +468,7 @@ def test_botservice_show_on_v4_js_webapp_bot(self, resource_group):
# clean up the folder
shutil.rmtree(dir_path)

self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Javascript',
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id} ',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -499,7 +498,7 @@ def test_botservice_show_on_v4_csharp_webapp_bot(self, resource_group):
# clean up the folder
shutil.rmtree(dir_path)

self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Csharp',
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id} ',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -527,7 +526,7 @@ def test_botservice_publish_remove_node_iis_files_if_not_already_local(self, res
# clean up the folder
shutil.rmtree(dir_path)

self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Javascript --echo',
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id} ',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -566,7 +565,7 @@ def test_prepare_publish_with_registration_bot_should_raise_error(self, resource
})

self.cmd(
'az bot create -k registration -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id} -p {password} --tags '
'az bot create -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id} --tags '
'key1=value1',
checks=[
self.check('name', '{botname}'),
Expand Down Expand Up @@ -651,7 +650,7 @@ def test_botservice_update_should_update_bot_properties(self, resource_group):

self.cmd('az bot delete -g {rg} -n {botname}')

self.cmd('az bot create -k registration -g {rg} -n {botname} --appid {app_id}',
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id}',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -691,48 +690,29 @@ def test_botservice_create_should_raise_error_for_invalid_app_id_args(self, reso
"for more information on App Registrations. See 'az bot create --help' for more CLI " \
"information."
try:
self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {numbers_id} -p {password} --lang '
'Javascript --echo')
self.cmd('az bot create -g {rg} -n {botname} --appid {numbers_id}')
raise AssertionError()
except CLIError as cli_error:
assert cli_error.__str__() == expected_error
except AssertionError:
raise AssertionError('should have thrown an error for appid that is not valid GUID.')

try:
self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {short_app_id} -p {password} --lang '
'Javascript --echo')
self.cmd('az bot create -g {rg} -n {botname} --appid {short_app_id}')
raise AssertionError()
except CLIError as cli_error:
assert cli_error.__str__() == expected_error
except AssertionError:
raise AssertionError('should have thrown an error for appid that is not valid GUID.')

try:
self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid "" -p {password} --lang '
'Javascript --echo')
self.cmd('az bot create -g {rg} -n {botname} --appid ""')
raise AssertionError()
except CLIError as cli_error:
assert cli_error.__str__() == expected_error
except AssertionError:
raise AssertionError('should have thrown an error for appid that is not valid GUID.')

@ResourceGroupPreparer(random_name_length=20)
def test_botservice_create_should_raise_error_for_empty_password_strings_for_webapp_bots(self, resource_group):
self.kwargs.update({
'botname': self.create_random_name(prefix='cli', length=15),
'app_id': str(uuid.uuid4())
})

try:
self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p "" --lang Javascript --echo')
raise AssertionError()
except CLIError as cli_error:
assert cli_error.__str__() == "--password cannot have a length of 0 for Web App Bots. This value is used to " \
"authorize calls to your bot. See 'az bot create --help'."
except AssertionError:
raise AssertionError('should have thrown an error for empty string passwords.')

@ResourceGroupPreparer(random_name_length=20)
def test_botservice_create_should_raise_error_with_no_password_for_webapp_bots(self, resource_group):
self.kwargs.update({
Expand All @@ -741,7 +721,7 @@ def test_botservice_create_should_raise_error_with_no_password_for_webapp_bots(s
})

try:
self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} --lang Javascript --echo')
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id}')
raise AssertionError()
except CLIError as cli_error:
assert cli_error.__str__() == "--password cannot have a length of 0 for Web App Bots. This value is used to " \
Expand All @@ -762,7 +742,7 @@ def test_botservice_should_throw_if_name_is_unavailable(self, resource_group):
})

self.cmd(
'az bot create -k registration -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id}',
'az bot create -g {rg} -n {botname} -d {description} -e {endpoint} --appid {app_id}',
checks=[
self.check('name', '{botname}'),
self.check('properties.description', '{description}'),
Expand All @@ -772,7 +752,7 @@ def test_botservice_should_throw_if_name_is_unavailable(self, resource_group):

try:
self.cmd(
'az bot create -k registration -g {rg2} -n {botname} -d {description} -e {endpoint} --appid {app_id}')
'az bot create -g {rg2} -n {botname} -d {description} -e {endpoint} --appid {app_id}')
raise AssertionError()
except CLIError as cli_error:
assert cli_error.__str__().startswith('Unable to create bot.\nReason: ')
Expand Down Expand Up @@ -822,7 +802,7 @@ def test_update_bot_should_raise_mutuallyexclusiveargumenterror(self, resource_g
})

self.cmd(
'az bot create -k registration -g {rg} -n {botname} --appid {app_id}',
'az bot create -g {rg} -n {botname} --appid {app_id}',
checks=[
self.check('name', '{botname}'),
])
Expand All @@ -846,7 +826,7 @@ def test_botservice_create_should_remove_invalid_char_from_name_when_registratio
'password': str(uuid.uuid4())
})

self.cmd('az bot create -k registration -g {rg} -n {botname} --appid {app_id} -p {password} '
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id} '
'-e https://testurl.com/api/messages',
checks={
self.check('resourceGroup', '{rg}'),
Expand All @@ -864,7 +844,7 @@ def test_botservice_create_should_remove_invalid_char_from_name_when_webapp(self
'password': str(uuid.uuid4())
})

self.cmd('az bot create -k webapp -g {rg} -n {botname} --appid {app_id} -p {password} --lang Javascript',
self.cmd('az bot create -g {rg} -n {botname} --appid {app_id} ',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{valid_bot_name}'),
Expand Down Expand Up @@ -898,7 +878,7 @@ def test_botservice_create_enable_encryption_then_disable(self, resource_group):
cmk_url = resultAzKey['key']['kid']

resultsCreate = self.cmd(
'az bot create -k registration -g {rg} -n {botname} --appid {app_id} --cmk-key-vault-key-url ' + cmk_url,
'az bot create -g {rg} -n {botname} --appid {app_id} --cmk-key-vault-key-url ' + cmk_url,
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -930,7 +910,7 @@ def test_botservice_update_enable_cmk(self, resource_group):

self.cmd('az bot delete -g {rg} -n {botname}')

resultsCreate = self.cmd('az bot create -k registration -g {rg} -n {botname} --appid {app_id}',
resultsCreate = self.cmd('az bot create -g {rg} -n {botname} --appid {app_id}',
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -989,7 +969,7 @@ def test_botservice_create_webapp_enable_encryption_then_disable(self, resource_
cmk_url = resultAzKey['key']['kid']

self.cmd(
'az bot create -k webapp -g {rg} -n {botname} --appid {app_id} --echo --lang Csharp --password {pass} --cmk-key-vault-key-url ' + cmk_url,
'az bot create -g {rg} -n {botname} --appid {app_id} --password {pass} --cmk-key-vault-key-url ' + cmk_url,
checks={
self.check('resourceGroup', '{rg}'),
self.check('id', '{botname}'),
Expand Down Expand Up @@ -1040,7 +1020,7 @@ def test_botservice_prepare_deploy_javascript_should_fail_with_proj_file_path(se

try:
prepare_webapp_deploy(language, code_dir, proj_file_path)
raise Exception("'az bot prepare-publish --lang Javascript' should have failed with --proj-file-path")
raise Exception("'az bot prepare-publish ' should have failed with --proj-file-path")
except CLIError as cli_error:
assert cli_error.__str__() == '--proj-file-path should not be passed in if language is not Csharp'
except Exception as error:
Expand Down Expand Up @@ -1126,7 +1106,7 @@ def test_botservice_prepare_deploy_csharp_no_proj_file(self):

try:
prepare_webapp_deploy(language, code_dir, proj_file_path)
raise Exception("'az bot prepare-publish --lang Csharp' should have failed with no --proj-file-path")
raise Exception("'az bot prepare-publish ' should have failed with no --proj-file-path")
except CLIError as cli_error:
assert cli_error.__str__() == '--proj-file-path must be provided if language is Csharp'

Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
'azure-mgmt-batchai==7.0.0b1',
'azure-mgmt-batch~=16.1.0',
'azure-mgmt-billing==6.0.0',
'azure-mgmt-botservice~=0.3.0',
'azure-mgmt-botservice~=1.0.0',
'azure-mgmt-cdn==12.0.0',
'azure-mgmt-cognitiveservices~=13.1.0',
'azure-mgmt-compute~=26.1.0',
Expand Down