def __init__(self, request):
     self.request = request
     self._settings = request.registry.settings
     self._data = self._settings['data']
     self.accounting = Accounting()
     self.authentication = AuthenticationManager()
     self.token = Token()
Exemple #2
0
def step_impl(context):
    context.usernew = {
        'token': 'abababab',
        'username': context.username,
        'email': '*****@*****.**',
        'fname': 'teste',
        'lname': 'teste'
    }
    context.userold = {'username': context.username}
    with patch.object(BaseDB, 'get') as mck_get:
        with patch.object(AuthenticationManager,
                          'verify_token',
                          return_value=True) as mck_verify:
            with patch.object(AuthenticationManager,
                              'delete_user',
                              return_value=1) as mck_delete:
                with patch.object(BaseDB, 'insert',
                                  return_value=1) as mck_insert:
                    authentication = AuthenticationManager()
                    result = authentication.update_user(
                        context.app_id, context.usernew)
                    assert mck_get.called
                    assert mck_verify.called
                    assert mck_delete.called
                    assert mck_insert.called
                    assert result > 0
Exemple #3
0
def step_impl(context):
    context.token = 'ababab'
    with patch.object(BaseDB, 'remove') as mck_remove:
        authentication = AuthenticationManager()
        context.result = authentication.remove_token(context.token)
        assert mck_remove.called
        assert mck_remove.called_with('Token', 'token', context.token)
Exemple #4
0
def step_impl(context):
    with patch.object(BaseDB, 'remove_list_item') as mck_remove:
        authentication = AuthenticationManager()
        context.result = authentication.delete_user(context.app_id,
                                                    context.user_info)
        assert mck_remove.called_with(USER_COLLECTION, APP_KEY, context.app_id,
                                      USER_ITEM, context.user_info)
Exemple #5
0
 def __init__(self, request):
     self.request = request
     self._settings = request.registry.settings
     self._data = self._settings['data']
     self.favorites = Favorites()
     self.authentication = AuthenticationManager()
     self.authorisation = Authorisation()
     self.token = Token()
 def __init__(self, request):
     self.request = request
     self._settings = request.registry.settings
     self._data = self._settings['data']
     self.authentication = AuthenticationManager()
     self.sendEmail = SendEmail()
     self.emailToken = EmailToken()
     self.token = Token()
Exemple #7
0
def step_impl(context):
    authentication = AuthenticationManager()
    context.result = authentication.generate_token(
        context.user_info).encode('utf-8')
    hashed = bcrypt.hashpw(
        (SECRET + json.dumps(context.user_info)).encode('utf-8'),
        base64.b64decode(context.result))
    assert base64.b64encode(hashed) == context.result
Exemple #8
0
def step_impl(context):
    authentication = AuthenticationManager()
    hashed = authentication._hashpwd('pwd')
    context.info = {'username': '******', 'password': hashed}
    ret = [{'auth': [context.info]}]
    with patch.object(BaseDB, 'get', return_value=ret) as mck_get:
        context.result = authentication.access_app(1, context.username,
                                                   context.password)
        assert mck_get.called
Exemple #9
0
def step_impl(context):
    with patch.object(AuthenticationManager,
                      '_is_user_unique',
                      return_value=True) as mck_unique:
        with patch.object(BaseDB, 'insert', return_value=None) as mck_insert:
            authentication = AuthenticationManager()
            result = authentication.insert_user(context.app_id,
                                                context.user_info)
            assert mck_insert.called
            assert mck_unique.called
Exemple #10
0
def step_impl(context):
    context.token = 'abababab'
    ret = [{
        'data': [{
            'app_id': context.app_id,
            'user': context.user_info
        }],
        'token': context.token
    }]
    with patch.object(BaseDB, 'get_all', return_value=ret) as mck_get:
        authentication = AuthenticationManager()
        context.result = authentication.get_token(context.app_id,
                                                  context.user_info)
Exemple #11
0
def step_impl(context):
    with patch.object(AuthenticationManager,
                      '_is_user_unique',
                      return_value=False) as mck_unique:
        with patch.object(BaseDB, 'insert', return_value=None) as mck_insert:
            authentication = AuthenticationManager()
            result = authentication.insert_user(context.app_id,
                                                context.user_info)
            assert not mck_insert.called
            assert mck_unique.called
            print(result)
            assert len(result) == 2
            assert result[0] == None
            assert result[1] == 'users'
Exemple #12
0
def step_impl(context):
    authentication = AuthenticationManager()
    for item in context.invalid_passwords:
        if not authentication.validate_pwd({
                'username': '******',
                'password': item,
                'fname': 'teste',
                'lname': 'teste',
                'email': '*****@*****.**'
        }):
            context.result = False
            context.value = item + ' is invalid'
    context.result = True
    context.value = 'valid'
Exemple #13
0
def step_impl(context):
    context.app_id = 1
    context.username = '******'
    context.user_info = {'username': context.username, 'password': '******'}
    context.token = 'ababab'
    context.data = {
        'app_id': context.app_id,
        'created': datetime.datetime.now(),
        'user': context.user_info
    }
    with patch.object(BaseDB, 'insert') as mck_insert:
        authentication = AuthenticationManager()
        context.result = authentication.insert_token(context.app_id,
                                                     context.user_info,
                                                     context.token)
        assert mck_insert.called
Exemple #14
0
def step_impl(context):
    context.app_id = 1
    context.username = '******'
    context.user_info = {'username': context.username, 'password': '******'}
    context.token = 'ababab'
    ret = [{
        'data': [{
            'app_id': context.app_id,
            'created': datetime.datetime.now(),
            'user': context.user_info
        }],
        'token':
        context.token
    }]
    with patch.object(BaseDB, 'get', return_value=ret) as mck_get:
        authentication = AuthenticationManager()
        context.result = authentication.verify_token(context.app_id,
                                                     context.token)
        assert mck_get.called
Exemple #15
0
 def __init__(self, request):
     self.request = request
     self._settings = request.registry.settings
     self.authentication = AuthenticationManager()
Exemple #16
0
def step_impl(context):
    with patch.object(BaseDB, 'remove') as mck_remove:
        authentication = AuthenticationManager()
        context.result = authentication.remove_app(context.app_id)
        assert mck_remove.called
        assert mck_remove.called_with(USER_COLLECTION, APP_KEY, context.app_id)