Added warning message while using the commands with ADO server (#1160)
* Warning messages added for ADO server * Strip the trailing slash * run style chagnes * White space removed * Style changes * Test cases and Message done * Method name changed and run style changes * Method name changes done * Code and Test case changes done * Message changed Co-authored-by: Roshan-sy <roshan-sy@github.com>
This commit is contained in:
Родитель
87d029a171
Коммит
0436ad302b
|
@ -355,6 +355,10 @@ def resolve_instance_project_and_repo(
|
|||
_raise_team_project_arg_error()
|
||||
if repo_required and repo is None:
|
||||
_raise_repo_requird_arg_error()
|
||||
|
||||
if not check_organization_in_azure(organization):
|
||||
logger.warning("The Azure DevOps Extension for the Azure CLI does not support Azure DevOps Server.")
|
||||
|
||||
return organization, project, repo
|
||||
|
||||
|
||||
|
@ -424,6 +428,12 @@ def get_project_id_from_name(organization, project):
|
|||
return project
|
||||
|
||||
|
||||
def check_organization_in_azure(organization):
|
||||
startsWith = organization.startswith("https://dev.azure.com/")
|
||||
endsWith = organization.rstrip("/").endswith(".visualstudio.com")
|
||||
return startsWith or endsWith
|
||||
|
||||
|
||||
_connection_data = {}
|
||||
_connection = OrderedDict()
|
||||
VSTS_MODULE = 'azext_devops.devops_sdk.'
|
||||
|
|
|
@ -20,12 +20,16 @@ from azext_devops.dev.common.telemetry import (set_tracking_data,
|
|||
from azext_devops.dev.common.services import (get_connection,
|
||||
clear_connection_cache,
|
||||
resolve_instance,
|
||||
resolve_instance_project_and_repo)
|
||||
resolve_instance_project_and_repo,
|
||||
check_organization_in_azure)
|
||||
|
||||
|
||||
class TestServicesMethods(unittest.TestCase):
|
||||
_TEST_DEVOPS_ORGANIZATION = 'https://dev.azure.com/AzureDevOpsCliTest'
|
||||
_TEST_DEVOPS_ORGANIZATION2 = 'https://dev.azure.com/MyOrganization'
|
||||
|
||||
_TEST_VISUAL_STUDIO_ORGANIZATION = 'https://mseng.visualstudio.com/'
|
||||
_TEST_ADO_SERVER_ORGANIZATION = 'http://desktop-mf32o61/DefaultCollection/'
|
||||
|
||||
def setUp(self):
|
||||
clear_connection_cache()
|
||||
|
@ -65,6 +69,18 @@ class TestServicesMethods(unittest.TestCase):
|
|||
resolve_instance(organization='myorg', detect=False)
|
||||
self.assertEqual(str(exc.exception), self.ORG_ERROR_STRING)
|
||||
|
||||
def test_check_organization_in_azure_with_dev_url(self):
|
||||
showWarning = check_organization_in_azure(self._TEST_DEVOPS_ORGANIZATION)
|
||||
self.assertEqual(True, showWarning)
|
||||
|
||||
def test_check_organization_in_azure_with_visual_studio_url(self):
|
||||
showWarning = check_organization_in_azure(self._TEST_VISUAL_STUDIO_ORGANIZATION)
|
||||
self.assertEqual(True, showWarning)
|
||||
|
||||
def test_check_organization_in_azure_with_ado_server_url(self):
|
||||
showWarning = check_organization_in_azure(self._TEST_ADO_SERVER_ORGANIZATION)
|
||||
self.assertEqual(False, showWarning)
|
||||
|
||||
ORG_ERROR_STRING = ('--organization must be specified. The value should be the URI of your Azure DevOps '
|
||||
'organization, for example: https://dev.azure.com/MyOrganization/ or your Azure DevOps Server organization. '
|
||||
'You can set a default value by running: az devops configure --defaults '
|
||||
|
|
Загрузка…
Ссылка в новой задаче