def test(syncgateway_public_url): user_client = UserClient(syncgateway_public_url) result = user_client.get_server() assert sorted(list(result)) == ["couchdb", "vendor", "version"] # No ADMIN key
def test_user_authed(database, syncgateway_public_url): user_client = UserClient(syncgateway_public_url) session = user_client.get_database('db').get_session() user = database.get_user('__USERNAME__') user.set_password('__PASSWORD__') user.set_admin_channels('a', 'b', 'c') user.create_update() user_client.auth('__USERNAME__', '__PASSWORD__') result = session.retrieve() assert result is True assert session.data == { 'authentication_handlers': ['default', 'cookie'], 'ok': True, 'userCtx': { 'channels': { '!': 1, 'a': 1, 'b': 1, 'c': 1, }, 'name': '__USERNAME__', }, }
def test_user_no_auth(database, syncgateway_public_url): user_client = UserClient(syncgateway_public_url) session = user_client.get_database('db').get_session() result = session.retrieve() assert result is True assert session.data == no_auth_response
def session(database, syncgateway_public_url): """ Returns: Session: With authenticated user '__USERNAME__' written to Sync Gateway. """ user_client = UserClient(syncgateway_public_url) session = user_client.get_database('db').get_session() user = database.get_user('__USERNAME__') user.set_password('__PASSWORD__') user.set_admin_channels('a', 'b', 'c') user.create_update() user_client.auth('__USERNAME__', '__PASSWORD__') return session
def user_client(syncgateway_public_url): """ Returns: UserClient: Unauthorized client. """ return UserClient(syncgateway_public_url)
def user_client(syncgateway_public_url): """ Returns: UserClient: Pointed at test public URL. """ return UserClient(syncgateway_public_url)
def test_user_no_auth_no_database(syncgateway_public_url): user_client = UserClient(syncgateway_public_url) session = user_client.get_database('db').get_session() with pytest.raises(DoesNotExist): session.retrieve()
def test(syncgateway_public_url): result = UserClient(syncgateway_public_url) assert result.url == syncgateway_public_url assert result._auth is None