Esempio n. 1
0
def getUUID(request, inHeader=False):
    try:
        retUUID = enaa.getUUID(request, auth_method, inHeader)
        logging.debug("retUUID = %s" % retUUID)
        if retUUID is None:
           raise HTTPError(403, "token is valid, but no account found for user")
        return retUUID
    except ValueError as e:
        traceback.print_exc()
        abort(401, e.message)
def getUUID(request, inHeader=False):
    try:
        retUUID = enaa.getUUID(request, auth_method, inHeader)
        logging.debug("retUUID = %s" % retUUID)
        if retUUID is None:
           raise HTTPError(403, "token is valid, but no account found for user")
        return retUUID
    except ValueError as e:
        traceback.print_exc()
        abort(401, e.message)
    def testGetUUIDSkipAuth(self):
        import emission.net.api.bottle as enab
        import emission.core.wrapper.user as ecwu
        import io

        self.test_email = "test_email"
        user_data = io.StringIO() 
        user_data.write(json.dumps({'user': self.test_email}))
        test_environ = etc.createDummyRequestEnviron(self, addl_headers=None, request_body=user_data)

        request = enab.LocalRequest(environ=test_environ)
        logging.debug("Found request body = %s" % request.body.getvalue())
        logging.debug("Found request headers = %s" % list(request.headers.keys()))
        user = ecwu.User.register(self.test_email)
        self.assertEqual(enaa.getUUID(request, "skip", inHeader=False), user.uuid)
        ecwu.User.unregister(self.test_email)
    def testGetUUIDTokenAuthFailure(self):
        import emission.net.api.bottle as enab
        import emission.core.wrapper.user as ecwu
        import io

        self.test_email = "correct_horse_battery_staple"
        user_data = io.StringIO() 
        user_data.write(json.dumps({'user': "******"}))
        test_environ = etc.createDummyRequestEnviron(self, addl_headers=None, request_body=user_data)

        request = enab.LocalRequest(environ=test_environ)
        logging.debug("Found request body = %s" % request.body.getvalue())
        logging.debug("Found request headers = %s" % list(request.headers.keys()))
        user = ecwu.User.register(self.test_email)
        ecwu.User.unregister(self.test_email)
        with self.assertRaises(ValueError):
            self.assertEqual(enaa.getUUID(request, "token_list", inHeader=False), user.uuid)
Esempio n. 5
0
    def testGetUUIDTokenAuthSuccess(self):
        import emission.net.api.bottle as enab
        import emission.core.wrapper.user as ecwu
        import io

        self.test_email = "correct_horse_battery_staple"
        user_data = io.StringIO()
        user_data.write(json.dumps({'user': self.test_email}))
        test_environ = etc.createDummyRequestEnviron(self,
                                                     addl_headers=None,
                                                     request_body=user_data)

        request = enab.LocalRequest(environ=test_environ)
        logging.debug("Found request body = %s" % request.body.getvalue())
        logging.debug("Found request headers = %s" %
                      list(request.headers.keys()))
        user = ecwu.User.register(self.test_email)
        self.assertEqual(enaa.getUUID(request, "token_list", inHeader=False),
                         user.uuid)
        ecwu.User.unregister(self.test_email)