Skip to content

Commit

Permalink
fixes for speedrun + new changes in mas
Browse files Browse the repository at this point in the history
- change ame to system_name in metrics and methods
- increase timeout for creating crs
- add oidc support
  • Loading branch information
mkudlej committed Mar 28, 2024
1 parent 0949d23 commit 467e126
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 117 deletions.
8 changes: 4 additions & 4 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def metric_params(service):
suffix = get_suffix()
friendly_name = f'test-metric-{suffix}'
name = f'{friendly_name}'.replace('-', '_')
return dict(friendly_name=friendly_name, name=name, unit='count')
return dict(friendly_name=friendly_name, system_name=name, unit='count')


@pytest.fixture(scope='module')
Expand All @@ -210,7 +210,7 @@ def backend_metric_params():
friendly_name = f'test-metric-{suffix}'
name = f'{friendly_name}'.replace('-', '')
return dict(friendly_name=friendly_name,
name=name, unit='count')
system_name=name, unit='count')


@pytest.fixture(scope='module')
Expand Down Expand Up @@ -264,7 +264,7 @@ def method(hits_metric, method_params):

@pytest.fixture(scope='module')
def hits_metric(service):
return service.metrics.read_by(name='hits')
return service.metrics.read_by(system_name='hits')


def get_mapping_rule_pattern():
Expand Down Expand Up @@ -431,7 +431,7 @@ def tenant_params():
"""
Params for custom tenant
"""
return dict(name=f"tenant{get_suffix()}",
return dict(username=f"tenant{get_suffix()}",
admin_password="123456",
email=f"e{get_suffix()}@invalid.invalid",
org_name="org")
Expand Down
40 changes: 10 additions & 30 deletions threescale_api_crd/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
'oidc': {
'oidc': {
'issuerEndpoint': None,
'issuerEndpoint': ' ',
'issuerType': 'keycloak',
'authenticationFlow': {
'standardFlowEnabled': False,
Expand Down Expand Up @@ -370,25 +370,6 @@
}
}

KEYS_PROXY_RESPONSES = {
'error_auth_failed': 'errorAuthFailed',
'error_auth_missing': 'errorAuthMissing',
'systemName': None,
'description': None,
'deployment': {
'apicastHosted': {
'authentication': {
'userkey': {
'authUserKey': 'token',
'credentials': 'query',
'gatewayResponse': {
},
},
},
},
}
}

KEYS_SERVICE = {
'description': 'description',
'name': 'name',
Expand Down Expand Up @@ -419,20 +400,20 @@

KEYS_PROXY_SECURITY = {
'secret_token': 'secretToken',
'host_header': 'hostHeader',
'hostname_rewrite': 'hostHeader',
}

KEYS_PROXY = {
'auth_app_id': 'appID',
'auth_app_key': 'appKey',
'auth_user_key': 'authUserKey',
'credentials_location': 'credentials',
'endpoint': 'productionPublicBaseURL',
'sandbox_endpoint': 'stagingPublicBaseURL',
'auth_user_key': 'authUserKey',
'auth_app_key': 'appKey',
'auth_app_id': 'appID',
'oidc_issuer_endpoint': 'issuerEndpoint',
'oidc_issuer_type': 'issuerType',
'jwt_claim_with_client_id': 'jwtClaimWithClientID',
'jwt_claim_with_client_id_type': 'jwtClaimWithClientIDType',
'oidc_issuer_endpoint': 'issuerEndpoint',
'oidc_issuer_type': 'issuerType',
'sandbox_endpoint': 'stagingPublicBaseURL',
}

KEYS_OIDC = {
Expand Down Expand Up @@ -482,7 +463,7 @@
'description': 'description',
'unit': 'unit',
'friendly_name': 'friendlyName',
'name': 'name'
'system_name': 'system_name'
}

KEYS_LIMIT = {
Expand Down Expand Up @@ -550,7 +531,6 @@
'jwtClaimWithClientID': 'jwtClaimWithClientID',
'jwtClaimWithClientIDType': 'jwtClaimWithClientIDType',
'credentials': 'credentials',
'security': 'security',
'gatewayResponse': 'gatewayResponse',
}

Expand Down Expand Up @@ -595,7 +575,7 @@
KEYS_METHOD = {
'description': 'description',
'friendly_name': 'friendlyName',
'name': 'name'
'system_name': 'system_name'
}

SPEC_SECRET = {
Expand Down
17 changes: 15 additions & 2 deletions threescale_api_crd/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ def read_by_name(self, name: str, **kwargs) -> 'DefaultResource':
"""
return self.fetch_crd_entity(name) or super().read_by_name(name, **kwargs)

# def read(self, entity_id: int = None) -> 'DefaultResource':
# """Read the instance, read will just create empty resource and lazyloads only if needed
# Args:
# entity_id(int): Entity id
# Returns(DefaultResource): Default resource
# """
# LOG.debug(self._log_message("[READ] CRD Read ", entity_id=entity_id))
# if self.is_crd_implemented():
# self.fetch(entity_id=entity_id)
# else:
# return threescale_api.defaults.DefaultClient.read(self, entity_id, **kwargs)


def fetch(self, entity_id: int = None, **kwargs):
"""Fetches the entity dictionary
Args:
Expand Down Expand Up @@ -134,7 +147,7 @@ def _list(self, **kwargs) -> List['DefaultResource']:
@staticmethod
def normalize(str_in: str):
"""Some values in CRD cannot contain some characters."""
return str_in.translate(''.maketrans({'-': '', '_': '', '/': ''})).lower()
return str_in.translate(''.maketrans({'-': '', '_': '', '/': '', '[': '', ']': ''})).lower()

@staticmethod
def cleanup_spec(spec, keys, params):
Expand Down Expand Up @@ -189,7 +202,7 @@ def create(self, params: dict = None, **kwargs) -> 'DefaultResource':
# if not list_objs:
# time.sleep(counters.pop())

timeout = 200
timeout = 1000
#if self.__class__.__name__ in ['Promotes']:
# timeout = 1000

Expand Down
Loading

0 comments on commit 467e126

Please sign in to comment.