Skip to content

Instantly share code, notes, and snippets.

@come-maiz
Last active December 6, 2016 14:02
Show Gist options
  • Save come-maiz/dffcda326f5b51feedeb09f012ac9a44 to your computer and use it in GitHub Desktop.
Save come-maiz/dffcda326f5b51feedeb09f012ac9a44 to your computer and use it in GitHub Desktop.
Synapse snap testing

Smoke tests for the Synapse snap

First, build and install the snap:

$ sudo apt install git snapcraft
$ git clone https://github.com/matrix-org/package-synapse-snap
$ cd package-synapse-snap
$ snapcraft
$ sudo snap install *.snap --dangerous

Set up a homeserver:

$ synapse.homeserver --generate-config --server-name machine1.local --config-path homeserver.yaml --report-stats=yes
A config file has been generated in 'homeserver.yaml' for server name 'machine1.local' with corresponding SSL keys and self-signed certificates. Please review this file and customise it to your needs.
If this server name is incorrect, you will need to regenerate the SSL certificates

Start the server:

$ synapse.synctl start
Starting ...
[...]
started synapse.app.homeserver('homeserver.yaml')

Register a user:

$ synapse.register-new-matrix-user -c homeserver.yaml https://localhost:8448
New user localpart [$user]:
Password: 
Confirm password: 
Make admin [no]:   

Login to the demo web client:

1. Open the browser.
2. Go to https://localhost:8448
3. Enter your `$user` as the `Matrix ID`.
4. Enter your `$password`.
5. Click the `Login` button.
   * Check that you are now in the main page.

Start a chat:

1. In the main page, enter `@$user:test-chat` in the `Start chat` textfield.
2. Click the `Start` button.
   * Check that the chat was added to the `Recent conversations` list.

Join a chat:

1. In the `Recent conversations` list, click the chat just added.
   * Check that you are now in the chat page.
2. Send a message to the chat.
@come-maiz
Copy link
Author

come-maiz commented Oct 5, 2016

Tested in an clean ubuntu xenial virtual machine with kvm.

Starting a chat shows an error dialog. This is written to the log:

2016-10-05 10:29:34,335 - twisted - 154 - INFO - POST-42- Stopping protocol <twisted.names.dns.DNSDatagramProtocol object at 0x7faa1113be10>
2016-10-05 10:29:34,337 - synapse.http.matrixfederationclient - 181 - WARNING - POST-42- {PUT-O-9} Sending request failed to test-chat: PUT matrix://test-chat/_matrix/federation/v1/invite/!EOZVWFJPhUaiiudzfB:machine1.local/$147568496919PpBhL:machine1.local: DNSLookupError - DNSLookupError: address 'test-chat' not found: [Errno -2] Name or service not known
2016-10-05 10:29:34,337 - synapse.http.outbound - 207 - INFO - POST-42- {PUT-O-9} [test-chat] Result: DNSLookupError - DNSLookupError: address 'test-chat' not found: [Errno -2] Name or service not known
2016-10-05 10:29:34,338 - synapse.http.server - 139 - ERROR - POST-42- Failed handle request synapse.http.server._async_render on <synapse.rest.ClientRestResource object at 0x7faa139cbcd0>: <SynapseRequest at 0x7faa1226eb00 method=POST uri=/_matrix/client/api/v1/createRoom?access_token=<redacted> clientproto=HTTP/1.1 site=8448>
Traceback (most recent call last):
  File "synapse/http/server.py", line 116, in wrapped_request_handler
    yield request_handler(self, request, request_metrics)
DNSLookupError: DNS lookup failed: address 'test-chat' not found: [Errno -2] Name or service not known.

This doesn't seem to break anything. I can access the chat.

@come-maiz
Copy link
Author

come-maiz commented Nov 24, 2016

Tested again today in a clean ubuntu xenial kvm.

The binaries are also logging a new apparmor denial:

= AppArmor =
Time: Nov 24 16:37:54
Log: apparmor="DENIED" operation="open" profile="snap.synapse.homeserver" name="/proc/22854/mounts" pid=22854 comm="python" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
File: /proc/22854/mounts (read)
Suggestions:
* adjust program to not access '@{PROC}/@{pid}/mounts'
* add one of 'mount-observe, network-control' to 'plugs'

= AppArmor =
Time: Nov 24 16:38:22
Log: apparmor="DENIED" operation="open" profile="snap.synapse.synctl" name="/proc/22877/mounts" pid=22877 comm="python" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
File: /proc/22877/mounts (read)
Suggestions:
* adjust program to not access '@{PROC}/@{pid}/mounts'
* add one of 'mount-observe, network-control' to 'plugs'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment