Improved a mock endpoint for testing import configuration modal

This commit is contained in:
VakarisZ 2021-06-01 10:31:59 +03:00
parent ff7760f202
commit 5ab0137f27
1 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,8 @@
import json
from dataclasses import dataclass from dataclasses import dataclass
import flask_restful import flask_restful
from flask import request
from common.utils.exceptions import ( from common.utils.exceptions import (
InvalidConfigurationError, InvalidConfigurationError,
@ -26,9 +28,9 @@ class TempConfiguration(flask_restful.Resource):
@jwt_required @jwt_required
def post(self): def post(self):
# request_contents = json.loads(request.data) request_contents = json.loads(request.data)
try: try:
self.decrypt() self.decrypt(request_contents["password"])
self.import_config() self.import_config()
return ResponseContents().form_response() return ResponseContents().form_response()
except InvalidCredentialsError: except InvalidCredentialsError:
@ -50,7 +52,11 @@ class TempConfiguration(flask_restful.Resource):
status_code=403, status_code=403,
).form_response() ).form_response()
def decrypt(self): def decrypt(self, password=""):
if not password:
raise NoCredentialsError
if not password == "abc":
raise InvalidCredentialsError
return False return False
def import_config(self): def import_config(self):