tests package#
Subpackages#
Submodules#
tests.client module#
- class tests.client.Client(host: str, port: str, server_hex_public_key: str, isTLS: bool)[source]#
Bases:
objectRepresents a client that interacts with a server using encryption.
- Args:
host (str): The hostname or IP address of the server. port (str): The port number of the server. server_hex_public_key (str): The server’s public key in hexadecimal format. isTLS (bool): Indicates whether to use TLS encryption.
- Attributes:
private_key (PrivateKey): The client’s private key. session (ClientSession): The client’s HTTP session. mail_box (MailBox): The client’s mailbox for encryption. ssl_context (SSLContext): The SSL context for TLS encryption.
- async connect_to_websocket(message) None[source]#
Connects to the websocket server.
- Args:
message: The message to be sent to the server.
- Returns:
None
- decrypt(encrypted_message) any[source]#
Decrypts an encrypted message using the mail_box’s unbox method.
- Args:
encrypted_message: The encrypted message to be decrypted.
- Returns:
The decrypted message.
- async disconnect() None[source]#
Disconnects the client from the server.
This method closes the session, terminating the connection with the server.
- encrypt(message) str[source]#
Encrypts the given message using the mail_box’s box method.
- Args:
message (str): The message to be encrypted.
- Returns:
str: The encrypted message.
- async fetch(url, params=None) any[source]#
Fetches data from the specified URL.
- Args:
url (str): The URL to fetch data from. params (dict, optional): The query parameters to include in the request. Defaults to None.
- Returns:
any: The response from the server, or None if an error occurred.
- private_key: PrivateKey#
- protocol() str[source]#
Returns the protocol used by the client.
If the client is using TLS, the protocol is “s”. If the client is not using TLS, the protocol is an empty string.
- Returns:
str: The protocol used by the client.
- async send_message(message) any[source]#
Sends a message to the server and returns the decrypted response.
- Args:
message: The message to be sent to the server.
- Returns:
The decrypted response from the server.
- Raises:
Any exceptions raised during the execution of the method.
- async send_websocket_message(message) None[source]#
Sends a WebSocket message after encrypting it.
- Args:
message: The message to be sent.
- Returns:
None
- session: ClientSession#
- socket: ClientWebSocketResponse#
- ssl_context: SSLContext#