def test_register_new_auth_key_supplying_both_key_and_id(
         self, mock_storage):
     result = authorization.register_new_auth_key(auth_key="test",
                                                  auth_key_id="yes")
     mock_storage.assert_called_with("KEYS/yes", result)
     self.assertEqual(result["key"], "test")
     self.assertEqual(result["id"], "yes")
 def test_register_new_auth_key_with_valid_data(self, mock_get_auth_key,
                                                mock_storage,
                                                mock_gen_key_id,
                                                mock_gen_key):
     self.assertRaises(ValueError, authorization.register_new_auth_key,
                       False, None, "id")
     result = authorization.register_new_auth_key()
     mock_storage.assert_called_with("KEYS/test_key_id", result)
     self.assertEqual(result["key"], "test_key")
     self.assertEqual(result["id"], "test_key_id")
Exemplo n.º 3
0
def create_api_key_v1(nickname: str = "") -> Dict[str, Any]:
    """
    Create a new api key
    Returns:
        newly created API keys
    """
    key = authorization.register_new_auth_key(nickname=nickname)
    return {
        "key": str(key["key"]),
        "id": str(key["id"]),
        "registration_time": int(key["registration_time"]),
        "nickname": str(key.get("nickname"))
    }
Exemplo n.º 4
0
 def populate_api_keys(self) -> None:
     key = authorization.register_new_auth_key(smart_contract=True)
     self.model.secrets["secret-key"] = key["key"]
     self.model.secrets["auth-key-id"] = key["id"]
     self.model.auth_key_id = key["id"]