Esempio n. 1
0
    def decoratedFunction(*args, **kwargs):
        service_key = request.headers.get('Authorization', None)

        if service_key is None:
            return responses.respondUnauthorized('No service key supplied')
        else:
            if service_key != os.environ['SERVICE_KEY']:
                return responses.respondUnauthorized('Incorrect service key')
            else:
                return f(*args, **kwargs)
Esempio n. 2
0
def test_common():
    '''test general files to improve coverage
    Simply run to make sure they dont crash the application
    '''
    from common import logger, responses
    logger.obj('string')

    app = Flask(__name__)

    with app.app_context():
        responses.respondInternalServerError()
        responses.respondOk('string')
        responses.respondUnauthorized('string')
Esempio n. 3
0
    def decoratedFunction(*args, **kwargs):
        email_address = None
        ticket_number = None

        if request.is_json:
            data = request.get_json()
            email_address = data.get('email_address')
            ticket_number = data.get('ticket_number')

        if email_address is None or ticket_number is None:
            return responses.respondUnauthorized(
                'No email address or ticket number supplied')
        else:
            guest = cache.get(email_address)

            if guest is None:
                return responses.respondUnauthorized('Incorrect email address')

            if ticket_number != guest['ticket_number']:
                return responses.respondUnauthorized('Incorrect ticket number')

        return f(*args, **kwargs, name=guest['name'])
Esempio n. 4
0
 def decoratedFunction(*args, **kwargs):
     token = request.headers.get('Token', None)
     if token is None:
         return responses.respondUnauthorized('No storage token sent')
     return f(*args, **kwargs)