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

fix uri #20632

Merged
merged 4 commits into from
Oct 18, 2021
Merged

fix uri #20632

Show file tree
Hide file tree
Changes from 3 commits
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
11 changes: 10 additions & 1 deletion sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# Release History

## 1.2.1 (Unreleased)
## 1.3.0 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

- Fix the issue that data was persisted according to an incorrect schema/in an incorrect format ([#20518](https://github.com/Azure/azure-sdk-for-python/issues/20518))

`SecretReferenceConfigurationSetting` in 1.2.0 used "secret_uri" rather than "uri" as the schema keywords which
broken inter-operation of `SecretReferenceConfigurationSetting` between SDK and the portal.

Please:
- Use 1.3.0+ for any `SecretReferenceConfigurationSetting` uses.
- Do a GET-AND-SET-BACK for existing `SecretReferenceConfigurationSetting`s to correct the format.
Copy link
Member

Choose a reason for hiding this comment

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

What is GET-AND-SET-BACK?

Copy link
Member Author

Choose a reason for hiding this comment

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

setting = get_config_setting()
set_config_setting(setting)

This can fix the ill-formed data.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: GET-AND-SET-BACK looks like a method in our codebase, can you change it to be more clear? You can add your answer above as an example to explain. Not sure if this is a proper way, just thinking aloud.


### Other Changes

## 1.2.0 (2021-07-06)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ def __init__(self, key, secret_id, **kwargs): # pylint: disable=super-init-not-
self.read_only = kwargs.get("read_only", None)
self.tags = kwargs.get("tags", {})
self.secret_id = secret_id
self._value = json.dumps({"secret_uri": secret_id})
self._value = json.dumps({"uri": secret_id})

@property
def value(self):
try:
temp = json.loads(self._value)
temp["secret_uri"] = self.secret_id
temp["uri"] = self.secret_id
self._value = json.dumps(temp)
return self._value
except (JSONDecodeError, ValueError):
Expand All @@ -325,7 +325,7 @@ def value(self, new_value):
try:
temp = json.loads(new_value)
self._value = new_value
self.secret_id = temp.get("secret_uri")
self.secret_id = temp.get("uri")
except(JSONDecodeError, ValueError):
self._value = new_value
self.secret_id = None
Expand All @@ -338,7 +338,9 @@ def _from_generated(cls, key_value):
secret_uri = None
try:
temp = json.loads(key_value.value) # type: ignore
secret_uri = temp.get("secret_uri")
secret_uri = temp.get("uri")
if not secret_uri:
secret_uri = temp.get("secret_uri")
except (ValueError, JSONDecodeError):
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Licensed under the MIT License.
# ------------------------------------

VERSION = "1.2.1"
VERSION = "1.3.0"
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ interactions:
message: OK
- request:
body: '{"key": "aref", "content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"value": "{\"secret_uri\": \"notaurl\"}", "tags": {}}'
"value": "{\"uri\": \"notaurl\"}", "tags": {}}'
headers:
Accept:
- application/vnd.microsoft.appconfig.kv+json
Expand All @@ -303,7 +303,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/aref?api-version=1.0
response:
body:
string: '{"etag":"XV3d02cqdYHZKgNdzki1wVDkyv5","key":"aref","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"XV3d02cqdYHZKgNdzki1wVDkyv5","key":"aref","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"notaurl\"}","tags":{},"locked":false,"last_modified":"2021-03-17T16:24:43+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -359,7 +359,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/aref?api-version=1.0
response:
body:
string: '{"etag":"XV3d02cqdYHZKgNdzki1wVDkyv5","key":"aref","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"XV3d02cqdYHZKgNdzki1wVDkyv5","key":"aref","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"notaurl\"}","tags":{},"locked":false,"last_modified":"2021-03-17T16:24:43+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -395,7 +395,7 @@ interactions:
code: 200
message: OK
- request:
body: '{"key": "aref1", "content_type": "fkaeyjfdkal;", "value": "{\"secret_uri\":
body: '{"key": "aref1", "content_type": "fkaeyjfdkal;", "value": "{\"uri\":
\"notaurl\"}", "tags": {}}'
headers:
Accept:
Expand All @@ -420,7 +420,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/aref1?api-version=1.0
response:
body:
string: '{"etag":"in0i0hpX7lRB0kHfOEuuxavvN4o","key":"aref1","label":null,"content_type":"fkaeyjfdkal;","value":"{\"secret_uri\":
string: '{"etag":"in0i0hpX7lRB0kHfOEuuxavvN4o","key":"aref1","label":null,"content_type":"fkaeyjfdkal;","value":"{\"uri\":
\"notaurl\"}","tags":{},"locked":false,"last_modified":"2021-03-17T16:24:43+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -476,7 +476,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/aref1?api-version=1.0
response:
body:
string: '{"etag":"in0i0hpX7lRB0kHfOEuuxavvN4o","key":"aref1","label":null,"content_type":"fkaeyjfdkal;","value":"{\"secret_uri\":
string: '{"etag":"in0i0hpX7lRB0kHfOEuuxavvN4o","key":"aref1","label":null,"content_type":"fkaeyjfdkal;","value":"{\"uri\":
\"notaurl\"}","tags":{},"locked":false,"last_modified":"2021-03-17T16:24:43+00:00"}'
headers:
access-control-allow-credentials:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ interactions:
message: OK
- request:
body: '{"key": "ConnectionString", "content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"value": "{\"secret_uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"value": "{\"uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"tags": {}}'
headers:
Accept:
Expand All @@ -304,7 +304,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"noRNIQV4p3jlzPGjmS8qNIARE4Z","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"noRNIQV4p3jlzPGjmS8qNIARE4Z","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:47+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -341,7 +341,7 @@ interactions:
message: OK
- request:
body: '{"key": "ConnectionString", "content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"value": "{\"secret_uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"value": "{\"uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"last_modified": "2021-03-30T16:18:47.000Z", "tags": {}, "locked": false, "etag":
"noRNIQV4p3jlzPGjmS8qNIARE4Z"}'
headers:
Expand All @@ -367,7 +367,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"inYK833dmGpyBM7jdlu69devKCI","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"inYK833dmGpyBM7jdlu69devKCI","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:48+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -425,7 +425,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"inYK833dmGpyBM7jdlu69devKCI","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"inYK833dmGpyBM7jdlu69devKCI","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:48+00:00"}'
headers:
access-control-allow-credentials:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ interactions:
message: OK
- request:
body: '{"key": "ConnectionString", "content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"value": "{\"secret_uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"value": "{\"uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"tags": {}}'
headers:
Accept:
Expand All @@ -304,7 +304,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"6DfiLycS3eX8Ba67imiq467YMwt","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"6DfiLycS3eX8Ba67imiq467YMwt","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:49+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -341,7 +341,7 @@ interactions:
message: OK
- request:
body: '{"key": "ConnectionString", "content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"value": "{\"secret_uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"value": "{\"uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"last_modified": "2021-03-30T16:18:49.000Z", "tags": {}, "locked": false, "etag":
"6DfiLycS3eX8Ba67imiq467YMwt"}'
headers:
Expand All @@ -367,7 +367,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"7NL7NOyLmOrwBLLaKJpGw5woPzk","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"7NL7NOyLmOrwBLLaKJpGw5woPzk","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:49+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -425,7 +425,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"7NL7NOyLmOrwBLLaKJpGw5woPzk","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"7NL7NOyLmOrwBLLaKJpGw5woPzk","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:49+00:00"}'
headers:
access-control-allow-credentials:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ interactions:
message: OK
- request:
body: '{"key": "ConnectionString", "content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"value": "{\"secret_uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"value": "{\"uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"tags": {}}'
headers:
Accept:
Expand All @@ -304,7 +304,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"o90RpwBMVBl2swER9FgYfVKcygT","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"o90RpwBMVBl2swER9FgYfVKcygT","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:51+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -341,7 +341,7 @@ interactions:
message: OK
- request:
body: '{"key": "ConnectionString", "content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"value": "{\"secret_uri\": \"https://test-test.vault.azure.net/new_secrets/connectionString\"}",
"value": "{\"uri\": \"https://test-test.vault.azure.net/new_secrets/connectionString\"}",
"last_modified": "2021-03-30T16:18:51.000Z", "tags": {}, "locked": false, "etag":
"o90RpwBMVBl2swER9FgYfVKcygT"}'
headers:
Expand All @@ -367,7 +367,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"ecPNJlEhWQ2IPgocOxQwQuOVG2q","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"ecPNJlEhWQ2IPgocOxQwQuOVG2q","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/new_secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:52+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -425,7 +425,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"ecPNJlEhWQ2IPgocOxQwQuOVG2q","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"ecPNJlEhWQ2IPgocOxQwQuOVG2q","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/new_secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:52+00:00"}'
headers:
access-control-allow-credentials:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ interactions:
message: OK
- request:
body: '{"key": "ConnectionString", "content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"value": "{\"secret_uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"value": "{\"uri\": \"https://test-test.vault.azure.net/secrets/connectionString\"}",
"tags": {}}'
headers:
Accept:
Expand All @@ -304,7 +304,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"uKrULBFGUzednnilA3kn8SXEDAM","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"uKrULBFGUzednnilA3kn8SXEDAM","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:54+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -341,7 +341,7 @@ interactions:
message: OK
- request:
body: '{"key": "ConnectionString", "content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"value": "{\"secret_uri\": \"https://test-test.vault.azure.net/new_secrets/connectionString\"}",
"value": "{\"uri\": \"https://test-test.vault.azure.net/new_secrets/connectionString\"}",
"last_modified": "2021-03-30T16:18:54.000Z", "tags": {}, "locked": false, "etag":
"uKrULBFGUzednnilA3kn8SXEDAM"}'
headers:
Expand All @@ -367,7 +367,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"d65cJir9UhQg8zEZBJgIQMOQ7sj","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"d65cJir9UhQg8zEZBJgIQMOQ7sj","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/new_secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:54+00:00"}'
headers:
access-control-allow-credentials:
Expand Down Expand Up @@ -425,7 +425,7 @@ interactions:
uri: https://fake_app_config.azconfig-test.io/kv/ConnectionString?api-version=1.0
response:
body:
string: '{"etag":"d65cJir9UhQg8zEZBJgIQMOQ7sj","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"secret_uri\":
string: '{"etag":"d65cJir9UhQg8zEZBJgIQMOQ7sj","key":"ConnectionString","label":null,"content_type":"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8","value":"{\"uri\":
\"https://test-test.vault.azure.net/new_secrets/connectionString\"}","tags":{},"locked":false,"last_modified":"2021-03-30T16:18:54+00:00"}'
headers:
access-control-allow-credentials:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ def test_config_setting_secret_reference(self, client):
new_uri2 = "https://aka.ms/azsdk/python"
updated_flag.secret_id = new_uri
temp = json.loads(updated_flag.value)
assert temp['secret_uri'] == new_uri
assert temp['uri'] == new_uri

updated_flag.value = json.dumps({'secret_uri': new_uri2})
updated_flag.value = json.dumps({'uri': new_uri2})
assert updated_flag.secret_id == new_uri2

set_flag.value = "bad_value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,9 @@ def test_config_setting_secret_reference(self, client):
new_uri2 = "https://aka.ms/azsdk/python"
updated_flag.secret_id = new_uri
temp = json.loads(updated_flag.value)
assert temp['secret_uri'] == new_uri
assert temp['uri'] == new_uri

updated_flag.value = json.dumps({'secret_uri': new_uri2})
updated_flag.value = json.dumps({'uri': new_uri2})
assert updated_flag.secret_id == new_uri2

set_flag.value = "bad_value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ def test_config_setting_secret_reference(self, client):
new_uri2 = "https://aka.ms/azsdk/python"
updated_flag.secret_id = new_uri
temp = json.loads(updated_flag.value)
assert temp['secret_uri'] == new_uri
assert temp['uri'] == new_uri

updated_flag.value = json.dumps({'secret_uri': new_uri2})
updated_flag.value = json.dumps({'uri': new_uri2})
assert updated_flag.secret_id == new_uri2

set_flag.value = "bad_value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,9 @@ def test_config_setting_secret_reference(self, client):
new_uri2 = "https://aka.ms/azsdk/python"
updated_flag.secret_id = new_uri
temp = json.loads(updated_flag.value)
assert temp['secret_uri'] == new_uri
assert temp['uri'] == new_uri

updated_flag.value = json.dumps({'secret_uri': new_uri2})
updated_flag.value = json.dumps({'uri': new_uri2})
assert updated_flag.secret_id == new_uri2

set_flag.value = "bad_value"
Expand Down