예제 #1
0
class UserTokenTestCase(TestCase):
    def setUp(self):
        self.service = ResetPasswordService("tokens", backend=get_backend())

    @patch("apps.auth.db.reset_password.get_random_string", return_value="random")
    def test_store_token(self, get_random_string):
        now = utcnow()
        doc = {"user": "******", "email": "*****@*****.**", "_id": "foo"}
        with patch.object(self.service.backend, "create") as create:
            with patch("apps.auth.db.reset_password.utcnow", return_value=now):
                self.service.store_reset_password_token(doc, doc["email"], 10, doc["_id"])
            create.assert_called_with(
                "tokens",
                [
                    {
                        "user": "******",
                        "email": "*****@*****.**",
                        "_id": "foo",
                        "_created": now,
                        "_updated": now,
                        "expire_time": now + timedelta(days=10),
                        "token": "random",
                    }
                ],
            )
예제 #2
0
class UserTokenTestCase(TestCase):

    def setUp(self):
        self.service = ResetPasswordService('tokens', backend=get_backend())

    @patch('apps.auth.db.reset_password.get_random_string', return_value='random')
    def test_store_token(self, get_random_string):
        now = utcnow()
        doc = {'user': '******', 'email': '*****@*****.**', '_id': 'foo'}
        with patch.object(self.service.backend, 'create') as create:
            with patch('apps.auth.db.reset_password.utcnow', return_value=now):
                self.service.store_reset_password_token(doc, doc['email'], 10, doc['_id'])
            create.assert_called_with('tokens', [{
                'user': '******',
                'email': '*****@*****.**',
                '_id': 'foo',
                '_created': now,
                '_updated': now,
                'expire_time': now + timedelta(days=10),
                'token': 'random',
            }])
예제 #3
0
class UserTokenTestCase(TestCase):
    def setUp(self):
        self.service = ResetPasswordService('tokens', backend=get_backend())

    @patch('apps.auth.db.reset_password.get_random_string',
           return_value='random')
    def test_store_token(self, get_random_string):
        now = utcnow()
        doc = {'user': '******', 'email': '*****@*****.**', '_id': 'foo'}
        with patch.object(self.service.backend, 'create') as create:
            with patch('apps.auth.db.reset_password.utcnow', return_value=now):
                self.service.store_reset_password_token(
                    doc, doc['email'], 10, doc['_id'])
            create.assert_called_with(
                'tokens', [{
                    'user': '******',
                    'email': '*****@*****.**',
                    '_id': 'foo',
                    '_created': now,
                    '_updated': now,
                    'expire_time': now + timedelta(days=10),
                    'token': 'random',
                }])
예제 #4
0
def init_app(app):
    endpoint_name = 'auth_db'
    service = AccessAuthService('auth', backend=superdesk.get_backend())
    AuthResource(endpoint_name, app=app, service=service)

    endpoint_name = 'reset_user_password'
    service = ResetPasswordService(endpoint_name, backend=superdesk.get_backend())
    ResetPasswordResource(endpoint_name, app=app, service=service)

    endpoint_name = 'change_user_password'
    service = ChangePasswordService(endpoint_name, backend=superdesk.get_backend())
    ChangePasswordResource(endpoint_name, app=app, service=service)

    endpoint_name = 'active_tokens'
    service = superdesk.Service(endpoint_name, backend=superdesk.get_backend())
    ActiveTokensResource(endpoint_name, app=app, service=service)
예제 #5
0
 def setUp(self):
     self.service = ResetPasswordService('tokens', backend=get_backend())
예제 #6
0
 def setUp(self):
     self.service = ResetPasswordService('tokens', backend=get_backend())