Beispiel #1
0
def requests_session(token):
    """
    Create a Requests API for testing, uses the token for auth
    """
    channel = fake_channel(token)
    requests_pb2_grpc.add_RequestsServicer_to_server(Requests(), channel)
    yield requests_pb2_grpc.RequestsStub(channel)
Beispiel #2
0
def requests_session(db, token):
    """
    Create a Requests API for testing, uses the token for auth
    """
    auth_interceptor = Auth(db).get_auth_interceptor(allow_jailed=False)
    user_id, jailed = Auth(db).get_session_for_token(token)
    channel = FakeChannel(user_id=user_id)
    requests_pb2_grpc.add_RequestsServicer_to_server(Requests(db), channel)
    yield requests_pb2_grpc.RequestsStub(channel)
Beispiel #3
0
    )
    server.add_insecure_port("[::]:1751")

    account_pb2_grpc.add_AccountServicer_to_server(Account(), server)
    api_pb2_grpc.add_APIServicer_to_server(servicer, server)
    communities_pb2_grpc.add_CommunitiesServicer_to_server(
        Communities(), server)
    conversations_pb2_grpc.add_ConversationsServicer_to_server(
        Conversations(), server)
    discussions_pb2_grpc.add_DiscussionsServicer_to_server(
        Discussions(), server)
    gis_pb2_grpc.add_GISServicer_to_server(GIS(), server)
    groups_pb2_grpc.add_GroupsServicer_to_server(Groups(), server)
    pages_pb2_grpc.add_PagesServicer_to_server(Pages(), server)
    references_pb2_grpc.add_ReferencesServicer_to_server(References(), server)
    requests_pb2_grpc.add_RequestsServicer_to_server(Requests(), server)
    search_pb2_grpc.add_SearchServicer_to_server(Search(), server)
    threads_pb2_grpc.add_ThreadsServicer_to_server(Threads(), server)

    server.start()

    media_server = grpc.server(
        futures.ThreadPoolExecutor(2),
        interceptors=[
            LoggingInterceptor(),
            get_media_auth_interceptor(
                config.config["MEDIA_SERVER_BEARER_TOKEN"])
        ],
    )
    media_server.add_insecure_port("[::]:1753")
    media_pb2_grpc.add_MediaServicer_to_server(Media(), media_server)