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

Get latest from azure dev #24

Merged
merged 35 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0fffa38
ppg create: `--type` is now optional. (#9391)
adewaleo May 15, 2019
06959cf
[functionapps] Improvements of devops-pipeline command (#9383)
May 15, 2019
10ddfee
role assignment: support scope of management group (#9321)
yugangw-msft May 15, 2019
eb20935
[function-app]: wording change from iteractive to interactive (#9402)
May 15, 2019
d32ae69
[Network] NAT Gateway support (#9379)
tjprescott May 15, 2019
f5811bc
[ACR] Support Managed Identities for Task (#9317)
jaysterp May 16, 2019
b58bea8
[webapp]Fixing bug where the result was not showing the ASP (#9408)
panchagnula May 16, 2019
f8cae01
BotService 0.2.1: Update help text, minor UX improvements (#9412)
stevengum May 16, 2019
ede98f5
Add support for Manual-Failover (#9413)
anusapan May 17, 2019
781320f
[core] Fix bug where --query cannot be used with --output yaml (#9403)
adewaleo May 20, 2019
0b40e75
update default log analytics workspace region mapping for aks monitor…
ganga1980 May 20, 2019
0bab75c
Fix JP installer line (#9438)
marstr May 20, 2019
6bf4f77
ACS - OSA - Whitelist message (#9409)
julienstroheker May 20, 2019
65f852a
release: update versions (#9418)
yugangw-msft May 16, 2019
6868f1f
[vm] Fix bug introduced in #9306. (#9421)
adewaleo May 17, 2019
1beb635
auth: handle unicode in subscription name when under python 2.7 (#9439)
yugangw-msft May 22, 2019
eece82c
role: update the help of --assignee-object-id (#9457)
yugangw-msft May 23, 2019
c234eac
Update error logging for reported unclear issues (#9180)
bgklein May 23, 2019
e991191
Enable/Disable AKS kube-dashboard addon (#9458)
zhedahht May 24, 2019
a933916
Added ACR command to create a buildpack task (#9366)
May 24, 2019
45579ca
Make the RPM Spec flexible to EL7 vs EL8 (#9394)
marstr May 28, 2019
cd0c342
[ACR] Return patch response directly for acr repository update (#9420)
djyou May 28, 2019
e3ab833
Fixing Dockerfile name of RPM builder for centos in pipeline definiti…
marstr May 28, 2019
6bb0734
test: fix a flaky test (#9494)
yugangw-msft May 29, 2019
d4b196d
Update _help.py (#9502)
macedogm May 29, 2019
c63361a
Added Error Message when no TTY is available (#9481)
jdeschenes May 30, 2019
250a590
[Network] AppGateway WAF Policy commands (#9470)
tjprescott May 30, 2019
3bdff7e
[vm] create now more intelligently uses image data disk lun info. (#9…
adewaleo May 30, 2019
99f4180
Fixed registry prefix check (#9509)
dorfire May 30, 2019
a61f180
Update CLI to use Knack 0.6.2 (preview mechanism) (#9456)
tjprescott May 31, 2019
b9596ff
Network API 2019-04-01 (#9523)
tjprescott May 31, 2019
3ff2c5f
support ssh_public_key (#9512)
aim-for-better May 31, 2019
29d0671
Fix #9489. (#9531)
tjprescott May 31, 2019
457e6f0
Fix #9443. (#9533)
tjprescott Jun 3, 2019
d1f11f3
ServiceBus: Fix for Issue 9319 (#9538)
Jun 3, 2019
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
auth: handle unicode in subscription name when under python 2.7 (Azur…
  • Loading branch information
yugangw-msft authored May 22, 2019
commit 1beb6352ece2d06187bbccd66f1638f45b0340f7
10 changes: 9 additions & 1 deletion src/azure-cli-core/azure/cli/core/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,18 @@ def find_subscriptions_on_login(self,

def _normalize_properties(self, user, subscriptions, is_service_principal, cert_sn_issuer_auth=None,
user_assigned_identity_id=None):
import sys
consolidated = []
for s in subscriptions:
display_name = s.display_name
try:
s.display_name.encode(sys.getdefaultencoding())
except (UnicodeEncodeError, UnicodeDecodeError): # mainly for Python 2.7 with ascii as the default encoding
display_name = re.sub(r'[^\x00-\x7f]', lambda x: '?', display_name)

consolidated.append({
_SUBSCRIPTION_ID: s.id.rpartition('/')[2],
_SUBSCRIPTION_NAME: s.display_name,
_SUBSCRIPTION_NAME: display_name,
_STATE: s.state.value,
_USER_ENTITY: {
_USER_NAME: user,
Expand All @@ -249,6 +256,7 @@ def _normalize_properties(self, user, subscriptions, is_service_principal, cert_
_TENANT_ID: s.tenant_id,
_ENVIRONMENT_NAME: self.cli_ctx.cloud.name
})

if cert_sn_issuer_auth:
consolidated[-1][_USER_ENTITY][_SERVICE_PRINCIPAL_CERT_SN_ISSUER_AUTH] = True
if user_assigned_identity_id:
Expand Down
16 changes: 16 additions & 0 deletions src/azure-cli-core/azure/cli/core/tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# pylint: disable=protected-access
import json
import os
import sys
import unittest
import mock
import re
Expand Down Expand Up @@ -106,6 +107,21 @@ def test_normalize(self):
# verify serialization works
self.assertIsNotNone(json.dumps(consolidated[0]))

def test_normalize_with_unicode_in_subscription_name(self):
cli = DummyCli()
storage_mock = {'subscriptions': None}
test_display_name = 'sub' + chr(255)
polished_display_name = 'sub?'
test_subscription = SubscriptionStub('sub1',
test_display_name,
SubscriptionState.enabled,
'tenant1')
profile = Profile(cli_ctx=cli, storage=storage_mock, use_global_creds_cache=False, async_persist=False)
consolidated = profile._normalize_properties(self.user1,
[test_subscription],
False)
self.assertTrue(consolidated[0]['name'] in [polished_display_name, test_display_name])

def test_update_add_two_different_subscriptions(self):
cli = DummyCli()
storage_mock = {'subscriptions': None}
Expand Down