Skip to content

Commit ceed943

Browse files
committed
add test
1 parent bb6d865 commit ceed943

File tree

4 files changed

+1886
-19
lines changed

4 files changed

+1886
-19
lines changed

src/azure-cli/azure/cli/command_modules/serviceconnector/_resource_config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class CLIENT_TYPE(Enum):
159159

160160
RESOURCE.FabricSql: 'https://api.fabric.microsoft.com/v1/workspaces/{fabric_workspace_uuid}/SqlDatabases/{fabric_sql_db_uuid}',
161161
RESOURCE.NeonPostgres: '/subscriptions/aaaabbbb-0000-cccc-1111-dddd2222eeee/resourceGroups/testrg/providers/Neon.Postgres/organizations/neontest',
162-
RESOURCE.MongoDbAtlas: '/subscriptions/aaaabbbb-0000-cccc-1111-dddd2222eeee/resourceGroups/testrg/providers/MongoDB.Atlas/organizations/mongotest'
162+
RESOURCE.MongoDbAtlas: '/subscriptions/aaaabbbb-0000-cccc-1111-dddd2222eeee/resourceGroups/{target_resource_group}/providers/MongoDB.Atlas/organizations/{server}'
163163

164164
}
165165

@@ -705,10 +705,10 @@ class CLIENT_TYPE(Enum):
705705
'help': 'The resource group which contains the MongoDB Atlas',
706706
'placeholder': 'MongoDBAtlasRG'
707707
},
708-
'target_service_name': {
709-
'options': ['--target-service-name'],
710-
'help': 'Name of the MongoDB Atlas service',
711-
'placeholder': 'MongoDBAtlasService'
708+
'server': {
709+
'options': ['--server'],
710+
'help': 'Name of the MongoDB Atlas server',
711+
'placeholder': 'MongoDBAtlasServer'
712712
}
713713
}
714714
}

src/azure-cli/azure/cli/command_modules/serviceconnector/_validators.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,24 +231,35 @@ def _infer_springcloud(source_id):
231231
logger.warning('Client type is not specified, use %s one: --client-type %s', method, client_type.value)
232232
return client_type.value
233233

234-
235-
def interactive_input(arg, hint):
234+
def interactive_input(arg, hint, cmd):
236235
'''Get interactive inputs from users
237236
'''
238237
value = None
239238
cmd_value = None
240239
if arg == 'secret_auth_info':
241-
name = prompt('User name of database (--secret name=): ')
242-
secret = prompt_pass('Password of database (--secret secret=): ')
243-
value = {
244-
'name': name,
245-
'secret_info': {
246-
'secret_type': 'rawValue',
247-
'value': secret
248-
},
249-
'auth_type': 'secret'
250-
}
251-
cmd_value = 'name={} secret={}'.format(name, '*' * len(secret))
240+
if 'mongodb-atlas' in cmd.name:
241+
secret = prompt_pass('Connection string of cluster (--secret secret=): ')
242+
value = {
243+
'name': 'NA',
244+
'secret_info': {
245+
'secret_type': 'rawValue',
246+
'value': secret
247+
},
248+
'auth_type': 'secret'
249+
}
250+
cmd_value = 'secret={}'.format('*' * len(secret))
251+
else:
252+
name = prompt('User name of database (--secret name=): ')
253+
secret = prompt_pass('Password of database (--secret secret=): ')
254+
value = {
255+
'name': name,
256+
'secret_info': {
257+
'secret_type': 'rawValue',
258+
'value': secret
259+
},
260+
'auth_type': 'secret'
261+
}
262+
cmd_value = 'name={} secret={}'.format(name, '*' * len(secret))
252263
elif arg == 'service_principal_auth_info_secret':
253264
client_id = prompt('ServicePrincipal client-id (--service-principal client_id=): ')
254265
object_id = prompt('Enterprise Application object-id (--service-principal object-id=): ')
@@ -373,7 +384,7 @@ def intelligent_experience(cmd, namespace, missing_args):
373384
for arg in missing_args:
374385
if arg not in cmd_arg_values:
375386
hint = '{} ({})'.format(missing_args[arg].get('help'), '/'.join(missing_args[arg].get('options')))
376-
value, cmd_value = interactive_input(arg, hint)
387+
value, cmd_value = interactive_input(arg, hint, cmd)
377388
cmd_arg_values[arg] = value
378389

379390
# show applied params

0 commit comments

Comments
 (0)