Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add pytest for fsread1 max_read_size validation #19194

Merged
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
3 changes: 2 additions & 1 deletion test/pytest/mocktransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ async def assert_empty(self):
assert self.queue.qsize() == 0

def send_json(self, _channel: str, **kwargs) -> None:
msg = {k.replace('_', '-'): v for k, v in kwargs.items()}
# max_read_size is one of our special keys which uses underscores
msg = {k.replace('_', '-') if k != "max_read_size" else k: v for k, v in kwargs.items()}
jelly marked this conversation as resolved.
Show resolved Hide resolved
self.send_data(_channel, json.dumps(msg).encode('ascii'))

def send_data(self, channel: str, data: bytes) -> None:
Expand Down
3 changes: 3 additions & 0 deletions test/pytest/test_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ async def test_fsread1_errors(transport):
await transport.check_open('fsread1', path='/etc/shadow', problem='access-denied')
await transport.check_open('fsread1', path='/', problem='internal-error',
reply_keys={'message': "[Errno 21] Is a directory: '/'"})
await transport.check_open('fsread1', path='/etc/passwd', max_read_size="lol",
problem='protocol-error',
reply_keys={'message': "max_read_size must be an integer"})


@pytest.mark.asyncio
Expand Down