def setUpClass(cls): super(ActionExecutionControllerTestCaseAuthEnabled, cls).setUpClass() cls.action = copy.deepcopy(ACTION_1) headers = { "content-type": "application/json", "X-Auth-Token": str(SYS_TOKEN.token), } post_resp = cls.app.post_json("/v1/actions", cls.action, headers=headers) cls.action["id"] = post_resp.json["id"] cls.action_encrypt = copy.deepcopy(ACTION_DEFAULT_ENCRYPT) post_resp = cls.app.post_json("/v1/actions", cls.action_encrypt, headers=headers) cls.action_encrypt["id"] = post_resp.json["id"] FixturesLoader().save_fixtures_to_db(fixtures_pack=FIXTURES_PACK, fixtures_dict=FIXTURES) # register datastore values which are used in this tests KeyValuePairAPI._setup_crypto() register_items = [ { "name": "secret", "secret": True, "value": crypto_utils.symmetric_encrypt(KeyValuePairAPI.crypto_key, "foo"), }, { "name": "user1:secret", "secret": True, "scope": FULL_USER_SCOPE, "value": crypto_utils.symmetric_encrypt(KeyValuePairAPI.crypto_key, "bar"), }, ] cls.kvps = [ KeyValuePair.add_or_update(KeyValuePairDB(**x)) for x in register_items ]
def setUpClass(cls): super(ActionExecutionControllerTestCaseAuthEnabled, cls).setUpClass() cls.action = copy.deepcopy(ACTION_1) headers = { 'content-type': 'application/json', 'X-Auth-Token': str(SYS_TOKEN.token) } post_resp = cls.app.post_json('/v1/actions', cls.action, headers=headers) cls.action['id'] = post_resp.json['id'] cls.action_encrypt = copy.deepcopy(ACTION_DEFAULT_ENCRYPT) post_resp = cls.app.post_json('/v1/actions', cls.action_encrypt, headers=headers) cls.action_encrypt['id'] = post_resp.json['id'] FixturesLoader().save_fixtures_to_db(fixtures_pack=FIXTURES_PACK, fixtures_dict=FIXTURES) # register datastore values which are used in this tests KeyValuePairAPI._setup_crypto() register_items = [ { 'name': 'secret', 'secret': True, 'value': crypto_utils.symmetric_encrypt(KeyValuePairAPI.crypto_key, 'foo') }, { 'name': 'user1:secret', 'secret': True, 'scope': FULL_USER_SCOPE, 'value': crypto_utils.symmetric_encrypt(KeyValuePairAPI.crypto_key, 'bar') }, ] cls.kvps = [ KeyValuePair.add_or_update(KeyValuePairDB(**x)) for x in register_items ]
def deserialize_key_value(value, secret=False): """ Deserialize the datastore item value. Note: Right now only strings as supported so only thing this function does is it decrypts secret values. :param value: Value to deserialize. :type value: ``str`` :param secret: True if a value is a secret and is encrypted. :type secret: ``bool`` """ if secret: KeyValuePairAPI._setup_crypto() value = symmetric_decrypt(KeyValuePairAPI.crypto_key, value) return value
def setUpClass(cls): super(ActionExecutionControllerTestCaseAuthEnabled, cls).setUpClass() cls.action = copy.deepcopy(ACTION_1) headers = {'content-type': 'application/json', 'X-Auth-Token': str(SYS_TOKEN.token)} post_resp = cls.app.post_json('/v1/actions', cls.action, headers=headers) cls.action['id'] = post_resp.json['id'] cls.action_encrypt = copy.deepcopy(ACTION_DEFAULT_ENCRYPT) post_resp = cls.app.post_json('/v1/actions', cls.action_encrypt, headers=headers) cls.action_encrypt['id'] = post_resp.json['id'] FixturesLoader().save_fixtures_to_db(fixtures_pack=FIXTURES_PACK, fixtures_dict=FIXTURES) # register datastore values which are used in this tests KeyValuePairAPI._setup_crypto() register_items = [ {'name': 'secret', 'secret': True, 'value': crypto_utils.symmetric_encrypt(KeyValuePairAPI.crypto_key, 'foo')}, {'name': 'user1:secret', 'secret': True, 'scope': FULL_USER_SCOPE, 'value': crypto_utils.symmetric_encrypt(KeyValuePairAPI.crypto_key, 'bar')}, ] cls.kvps = [KeyValuePair.add_or_update(KeyValuePairDB(**x)) for x in register_items]