Esempio n. 1
0
def execute(screen_name, email_address, password):
    click.echo('Creating user "{}" ... '.format(screen_name), nl=False)

    user = _create_user(screen_name, email_address)
    password_service.create_password_hash(user.id, password)

    click.secho('done.', fg='green')
def execute(screen_name, email_address, password):
    click.echo('Creating user "{}" ... '.format(screen_name), nl=False)

    user = _create_user(screen_name, email_address)
    password_service.create_password_hash(user.id, password)

    click.secho('done.', fg='green')
Esempio n. 3
0
def test_update_password_hash(party_app_with_db, admin_user, normal_user):
    admin_id = admin_user.id
    user_id = normal_user.id

    password_service.create_password_hash(user_id, 'InitialPassw0rd')

    password_hash_before = get_password_hash(user_id)
    assert password_hash_before is not None

    events_before = event_service.get_events_for_user(user_id)
    assert len(events_before) == 0

    # -------------------------------- #

    password_service.update_password_hash(user_id, 'ReplacementPassw0rd',
                                          admin_id)

    # -------------------------------- #

    password_hash_after = get_password_hash(user_id)
    assert password_hash_after is not None
    assert password_hash_after != password_hash_before

    events_after = event_service.get_events_for_user(user_id)
    assert len(events_after) == 1

    password_updated_event = events_after[0]
    assert password_updated_event.event_type == 'password-updated'
    assert password_updated_event.data == {
        'initiator_id': str(admin_id),
    }
Esempio n. 4
0
    def test_update_password_hash(self):
        orga_id = self.create_user('Party_Orga').id

        user = self.create_user('Party_User')
        user_id = user.id
        password_service.create_password_hash(user_id, 'InitialPassw0rd')

        password_hash_before = get_password_hash(user_id)
        assert password_hash_before is not None

        events_before = event_service.get_events_for_user(user_id)
        assert len(events_before) == 0

        # -------------------------------- #

        password_service.update_password_hash(user_id, 'ReplacementPassw0rd', orga_id)

        # -------------------------------- #

        password_hash_after = get_password_hash(user_id)
        assert password_hash_after is not None
        assert password_hash_after != password_hash_before

        events_after = event_service.get_events_for_user(user_id)
        assert len(events_after) == 1

        password_updated_event = events_after[0]
        assert password_updated_event.event_type == 'password-updated'
        assert password_updated_event.data == {
            'initiator_id': str(orga_id),
        }
Esempio n. 5
0
    def test_when_logged_in_endpoint_is_available(self):
        old_password = '******'
        new_password = '******'

        user = create_user()
        password_service.create_password_hash(user.id, old_password)
        login_user(user.id)

        credential_before = self.find_credential(user.id)
        assert credential_before is not None

        session_token_before = self.find_session_token(user.id)
        assert session_token_before is not None

        form_data = {
            'old_password': old_password,
            'new_password': new_password,
            'new_password_confirmation': new_password,
        }

        response = self.send_request(form_data, user_id=user.id)

        assert response.status_code == 302
        assert response.headers.get(
            'Location') == 'http://example.com/authentication/login'

        credential_after = self.find_credential(user.id)
        session_token_after = self.find_session_token(user.id)

        assert credential_after is not None
        assert credential_before.password_hash != credential_after.password_hash
        assert credential_before.updated_at != credential_after.updated_at

        # Session token should have been removed after password change.
        assert session_token_after is None
Esempio n. 6
0
    def create_user(self, password):
        user = create_user(8516)

        self.db.session.add(user)
        self.db.session.commit()

        password_service.create_password_hash(user.id, password)

        return user
    def create_user(self, password):
        user = create_user(8516)

        self.db.session.add(user)
        self.db.session.commit()

        password_service.create_password_hash(user.id, password)

        return user