def test_update_password(self, update_user):
        instance = DjangoCredentialRepository()

        credential = Credential('john.smith', uuid=UUID_MOCK)
        credential.set_password('P@ssw0rd')
        credential = instance.update_password(credential)

        assert bool(credential.password) is True
    def test_update_active_attribute(self, update_user):
        instance = DjangoCredentialRepository()

        credential = Credential('john.smith', 'P@ssw0rd', uuid=UUID_MOCK)
        credential.deactivate()

        credential = instance.update_status(credential)

        assert credential.active is False
 def _factory_credential(self, user: UserAccount) -> Credential:
     if user:
         return Credential(
             user.username,
             user.password,
             uuid=user.uuid,
             active=user.is_active
         )
    def test_return_credential(self, mocker):
        user = UserAccount(username='******', password='******')
        mocker.patch.object(UserAccount, 'save', return_value=user)

        instance = DjangoCredentialRepository()
        new_credential = instance.create(
            Credential(user.username, user.password))

        assert isinstance(new_credential, Credential)
Exemplo n.º 5
0
    def test_when_username_does_not_exists_persists_the_data(
            self, get_instance, mocker):
        instance = get_instance

        EmptyRepository.create = mocker.MagicMock(
            return_value=Credential('smith'))

        instance.execute()
        assert EmptyRepository.create.called
Exemplo n.º 6
0
def create_credential_response(mocker):
    credential = Credential('john.smith', 'P@ssw0rd')

    mocker.patch.object(DjangoCredentialRepository,
                        'create',
                        return_value=credential)

    mocker.patch.object(DjangoCredentialRepository,
                        'find_by',
                        return_value=None)

    instance = AuthService()
    return instance.create_credential('john.smith', 'P@ssw0rd')
    def test_persist_user_account(self, update_user):
        instance = DjangoCredentialRepository()
        instance.update_password(
            Credential('john.smith4', 'P@ssw0rd', uuid=UUID_MOCK))

        assert update_user.called is True
    def test_persist_user_account(self, mocker):
        create_user = mocker.patch.object(UserAccount, 'save')
        instance = DjangoCredentialRepository()
        instance.create(Credential('john.smith4', 'P@ssw0rd'))

        assert create_user.called is True
Exemplo n.º 9
0
 def find_by(self, username):
     return Credential(username, 'P@ssw0rd')
Exemplo n.º 10
0
 def _factory_credential(self) -> Credential:
     instance = Credential(self.__username)
     instance.set_password(self.__password)
     return instance
Exemplo n.º 11
0
def get_instance():
    return Credential('john.smith')
Exemplo n.º 12
0
 def test_when_password_is_provided_set_credential_password(self):
     instance = Credential('john.smith', 'P@ssw0rd')
     assert isinstance(instance.password, Password)
Exemplo n.º 13
0
    def test_when_active_is_provided_set_credential_active(self):
        expected_result = False

        instance = Credential('john.smith', active=expected_result)
        assert instance.active == expected_result
Exemplo n.º 14
0
 def test_when_username_is_not_provided_raise_exception(self):
     with pytest.raises(ValueError):
         Credential(None)
Exemplo n.º 15
0
    def test_when_uuid_is_provided_set_credential_uuid(self):
        expected_result = uuid4()
        instance = Credential('john.smith', uuid=expected_result)

        assert instance.uuid == expected_result