Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def modify(self, name: str, data: dict) -> BasicResponse:
:rtype: class:`ai_api_client_sdk.models.base_models.BasicResponse`
"""
body = {'data': data}
response_dict = self.rest_client.patch(path=f'{self.__PATH}/{name}', body=body)
headers = {'Content-Type': 'application/merge-patch+json'}
response_dict = self.rest_client.patch(path=f'{self.__PATH}/{name}', body=body, headers=headers)
return BasicResponse.from_dict(response_dict)

def query(self, top: int = None, skip: int = None) -> DockerRegistrySecretQueryResponse:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def delete(self, name: str, resource_group: str = None, ai_tenant_scope=True) ->

response_dict = self.rest_client.delete(path=f'{self.__PATH}/{name}', resource_group=resource_group,
headers=headers)
if response_dict == 200:
if response_dict == 200 or response_dict == '':
response_dict = { "message": "Secret has been deleted" }
return Message.from_dict(response_dict)

Expand Down
14 changes: 11 additions & 3 deletions packages/core/integration_tests/test_e2e_secrets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import base64
from typing import List

from . import get_random_string
Expand All @@ -7,13 +8,17 @@

class TestE2ESecrets(AICoreV2ClientE2ETestBase):

@staticmethod
def _get_random_b64_encoded_string():
return base64.b64encode(get_random_string().encode()).decode()

@staticmethod
def _get_secret_data():
return {
'name': f'test-{get_random_string()}',
'data': {
"prop1": get_random_string(),
"prop2": get_random_string()
"prop1": TestE2ESecrets._get_random_b64_encoded_string(),
"prop2": TestE2ESecrets._get_random_b64_encoded_string()
}
}

Expand Down Expand Up @@ -43,7 +48,10 @@ def test_secrets(self):
secrets_skip = self.ai_core_v2_client.secrets.query(skip=1, ai_tenant_scope=False)
self.assertEqual(n-1, len(secrets_skip.resources))

patch_data = {"prop1": get_random_string(), "prop2": get_random_string()}
patch_data = {
"prop1": self._get_random_b64_encoded_string(),
"prop2": self._get_random_b64_encoded_string()
}
response = self.ai_core_v2_client.secrets.modify(name=secret_dict['name'],
data=patch_data,
ai_tenant_scope=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def test_modify_deployment(self):
body = {'data': drs_dict['data']}
self.rest_client_mock.patch.return_value = response_dict
br = self.client.modify(name=drs_dict['name'], **body)
self.rest_client_mock.patch.assert_called_with(path=f'{self.drs_path}/{drs_dict["name"]}', body=body)
headers = { 'Content-Type': 'application/merge-patch+json' }
self.rest_client_mock.patch.assert_called_with(path=f'{self.drs_path}/{drs_dict["name"]}', body=body, headers=headers)
self.assertEqual(response_dict['id'], br.id)
self.assertEqual(response_dict['message'], br.message)

Expand Down