mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 03:17:13 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
103 lines
3 KiB
Nix
103 lines
3 KiB
Nix
import ../make-test-python.nix (
|
|
{ pkgs, ... }:
|
|
let
|
|
homeserverUrl = "http://homeserver:8008";
|
|
|
|
private_key = pkgs.runCommand "matrix_key.pem" {
|
|
buildInputs = [ pkgs.dendrite ];
|
|
} "generate-keys --private-key $out";
|
|
in
|
|
{
|
|
name = "dendrite";
|
|
meta = with pkgs.lib; {
|
|
maintainers = teams.matrix.members;
|
|
};
|
|
|
|
nodes = {
|
|
homeserver =
|
|
{ pkgs, ... }:
|
|
{
|
|
services.dendrite = {
|
|
enable = true;
|
|
loadCredential = [ "test_private_key:${private_key}" ];
|
|
openRegistration = true;
|
|
settings = {
|
|
global.server_name = "test-dendrite-server.com";
|
|
global.private_key = "$CREDENTIALS_DIRECTORY/test_private_key";
|
|
client_api.registration_disabled = false;
|
|
};
|
|
};
|
|
|
|
networking.firewall.allowedTCPPorts = [ 8008 ];
|
|
};
|
|
|
|
client =
|
|
{ pkgs, ... }:
|
|
{
|
|
environment.systemPackages = [
|
|
(pkgs.writers.writePython3Bin "do_test" { libraries = [ pkgs.python3Packages.matrix-nio ]; } ''
|
|
import asyncio
|
|
|
|
from nio import AsyncClient
|
|
|
|
|
|
async def main() -> None:
|
|
# Connect to dendrite
|
|
client = AsyncClient("http://homeserver:8008", "alice")
|
|
|
|
# Register as user alice
|
|
response = await client.register("alice", "my-secret-password")
|
|
|
|
# Log in as user alice
|
|
response = await client.login("my-secret-password")
|
|
|
|
# Create a new room
|
|
response = await client.room_create(federate=False)
|
|
room_id = response.room_id
|
|
|
|
# Join the room
|
|
response = await client.join(room_id)
|
|
|
|
# Send a message to the room
|
|
response = await client.room_send(
|
|
room_id=room_id,
|
|
message_type="m.room.message",
|
|
content={
|
|
"msgtype": "m.text",
|
|
"body": "Hello world!"
|
|
}
|
|
)
|
|
|
|
# Sync responses
|
|
response = await client.sync(timeout=30000)
|
|
|
|
# Check the message was received by dendrite
|
|
last_message = response.rooms.join[room_id].timeline.events[-1].body
|
|
assert last_message == "Hello world!"
|
|
|
|
# Leave the room
|
|
response = await client.room_leave(room_id)
|
|
|
|
# Close the client
|
|
await client.close()
|
|
|
|
asyncio.get_event_loop().run_until_complete(main())
|
|
'')
|
|
];
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
|
|
with subtest("start the homeserver"):
|
|
homeserver.wait_for_unit("dendrite.service")
|
|
homeserver.wait_for_open_port(8008)
|
|
|
|
with subtest("ensure messages can be exchanged"):
|
|
client.succeed("do_test")
|
|
'';
|
|
|
|
}
|
|
)
|