Exemplo n.º 1
0
def test_create_user(session_browser):
    """Test creating a user."""
    if functional.user_exists(session_browser, 'alice'):
        functional.delete_user(session_browser, 'alice')

    functional.create_user(session_browser, 'alice')
    assert functional.user_exists(session_browser, 'alice')
Exemplo n.º 2
0
    def test_all_repos_private(self, session_browser):
        """Test repo accessability when all repos are private."""
        _create_repo(session_browser,
                     'Test-repo',
                     'private',
                     ok_if_exists=True)
        _set_all_repos_private(session_browser)
        if not functional.user_exists(session_browser, 'gitweb_user'):
            functional.create_user(session_browser,
                                   'gitweb_user',
                                   groups=['git-access'])
        if not functional.user_exists(session_browser, 'nogroupuser'):
            functional.create_user(session_browser, 'nogroupuser', groups=[])

        functional.login_with_account(session_browser, functional.base_url,
                                      'gitweb_user')
        assert functional.is_available(session_browser, 'gitweb')
        assert len(functional.find_on_front_page(session_browser,
                                                 'gitweb')) == 1

        functional.login_with_account(session_browser, functional.base_url,
                                      'nogroupuser')
        assert not functional.is_available(session_browser, 'gitweb')
        assert len(functional.find_on_front_page(session_browser,
                                                 'gitweb')) == 0

        functional.logout(session_browser)
        functional.access_url(session_browser, 'gitweb')
        assert functional.is_login_prompt(session_browser)
        assert len(functional.find_on_front_page(session_browser,
                                                 'gitweb')) == 0
Exemplo n.º 3
0
def test_rename_user(session_browser):
    """Test renaming a user."""
    _non_admin_user_exists(session_browser, 'alice')
    if functional.user_exists(session_browser, 'bob'):
        functional.delete_user(session_browser, 'bob')

    _rename_user(session_browser, 'alice', 'bob')
    assert not functional.user_exists(session_browser, 'alice')
    assert functional.user_exists(session_browser, 'bob')
Exemplo n.º 4
0
    def test_user_group(self, session_browser):
        """Test that only users in vpn group have access."""
        functional.app_enable(session_browser, 'openvpn')
        if not functional.user_exists(session_browser, 'vpnuser'):
            functional.create_user(session_browser, 'vpnuser', groups=['vpn'])
        if not functional.user_exists(session_browser, 'nonvpnuser'):
            functional.create_user(session_browser, 'nonvpnuser', groups=[])

        functional.login_with_account(session_browser, base_url, 'vpnuser')
        _download_profile(session_browser)

        functional.login_with_account(session_browser, base_url, 'nonvpnuser')
        _not_on_front_page(session_browser)

        functional.login(session_browser)
Exemplo n.º 5
0
    def test_bittorrent_group(self, session_browser):
        """Test if only users in bit-torrent group can access Deluge."""
        functional.app_enable(session_browser, 'deluge')
        if not functional.user_exists(session_browser, 'delugeuser'):
            functional.create_user(session_browser, 'delugeuser',
                                   groups=['bit-torrent'])

        if not functional.user_exists(session_browser, 'nogroupuser'):
            functional.create_user(session_browser, 'nogroupuser')

        functional.login_with_account(session_browser, functional.base_url,
                                      'delugeuser')
        assert functional.is_available(session_browser, 'deluge')

        functional.login_with_account(session_browser, functional.base_url,
                                      'nogroupuser')
        assert not functional.is_available(session_browser, 'deluge')

        functional.login(session_browser)
Exemplo n.º 6
0
    def test_user_group_access(self, session_browser):
        """Test that only users in syncthing-access group can access syncthing
        site."""
        functional.app_enable(session_browser, self.app_name)
        if not functional.user_exists(session_browser, 'syncthinguser'):
            functional.create_user(session_browser, 'syncthinguser',
                                   groups=['syncthing-access'])
        if not functional.user_exists(session_browser, 'nogroupuser'):
            functional.create_user(session_browser, 'nogroupuser')

        functional.login_with_account(session_browser, functional.base_url,
                                      'syncthinguser')
        assert functional.is_available(session_browser, self.app_name)

        functional.login_with_account(session_browser, functional.base_url,
                                      'nogroupuser')
        assert not functional.is_available(session_browser, self.app_name)

        functional.login(session_browser)
Exemplo n.º 7
0
def user_does_not_exist(session_browser, name):
    if functional.user_exists(session_browser, name):
        functional.delete_user(session_browser, name)
Exemplo n.º 8
0
def admin_user_exists(session_browser, name):
    if functional.user_exists(session_browser, name):
        functional.delete_user(session_browser, name)
    functional.create_user(session_browser, name, groups=['admin'])
Exemplo n.º 9
0
def new_user_is_not_listed(session_browser, name):
    assert not functional.user_exists(session_browser, name)
Exemplo n.º 10
0
def _non_admin_user_exists(session_browser, name):
    if functional.user_exists(session_browser, name):
        functional.delete_user(session_browser, name)
    functional.create_user(session_browser, name)
Exemplo n.º 11
0
def test_delete_user(session_browser):
    """Test deleting a user."""
    _non_admin_user_exists(session_browser, 'alice')
    functional.delete_user(session_browser, 'alice')
    assert not functional.user_exists(session_browser, 'alice')
Exemplo n.º 12
0
def user_in_group_exists(session_browser, name, group):
    if functional.user_exists(session_browser, name):
        functional.delete_user(session_browser, name)
    functional.create_user(session_browser, name, groups=[group])