Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
7 changes: 5 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ name = grpc_requests
# Version needs regex in setup.py.
url = https://github.com/wesky93/grpc_requests
license = Apache License 2.0
maintainer = wesky93
maintainer_email = wesky93@gmail.com
author = wesky93
author_email = wesky93@gmail.com
maintainer = ViridianForge
maintainer_email = wayne@viridianforge.tech
description = grpc for Humans. grpc reflection support client
long_description = file: README.md, CHANGELOG.md
long_description_content_type = text/markdown
Expand All @@ -19,6 +21,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Software Development :: Libraries :: Python Modules


Expand Down
2 changes: 1 addition & 1 deletion src/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ header.
```python
from grpc_requests import Client

metadata = [{"authorization", f"bearer {my_bearer_token}"]
metadata = [("authorization", f"bearer {my_bearer_token}")]
client = Client.get_by_endpoint("my.supercool.hostname:443", ssl=True, metadata=metadata)

health_response = client.request('grpc.health.v1.Health', 'Check', {}, metadata=metadata)
Expand Down
9 changes: 9 additions & 0 deletions src/tests/reflection_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ def client_tester_reflection_client():
except: # noqa: E722
pytest.fail("Could not connect to local Test server")

def test_metadata_usage(helloworld_reflection_client):
response = helloworld_reflection_client.request(
'helloworld.Greeter', 'SayHello',
{"name": "sinsky"},
metadata=[('password', '12345')]
)
assert isinstance(response, dict)
assert response == {"message": "Hello, sinsky, password accepted!"}


def test_unary_unary(helloworld_reflection_client):
response = helloworld_reflection_client.request('helloworld.Greeter', 'SayHello', {"name": "sinsky"})
Expand Down
11 changes: 10 additions & 1 deletion src/tests/test_servers/helloworld/helloworld_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ def SayHello(self, request, context):
Unary-Unary
Sends a HelloReply based on a HelloRequest.
"""
return HelloReply(message=f"Hello, {request.name}!")
authorized = False
if context.invocation_metadata():
for key, value in context.invocation_metadata():
if key == "password" and value == "12345":
authorized = True

if authorized:
return HelloReply(message=f"Hello, {request.name}, password accepted!")
else:
return HelloReply(message=f"Hello, {request.name}!")

def SayHelloGroup(self, request, context):
"""
Expand Down