Alfonso Sanchez-Beato has proposed merging 
~alfonsosanchezbeato/network-manager:test-ci into network-manager:snap-1.10.

Commit message:
* Add iptables to the snap
* Do not call nmcli while NM is not running
* Add spread tests

Requested reviews:
  Network-manager (network-manager)

For more details, see:
https://code.launchpad.net/~alfonsosanchezbeato/network-manager/+git/network-manager/+merge/368284

* Add iptables to the snap
* Do not call nmcli while NM is not running
* Add spread tests
-- 
Your team Network-manager is requested to review the proposed merge of 
~alfonsosanchezbeato/network-manager:test-ci into network-manager:snap-1.10.
diff --git a/docs/snap/configure-cellular-connections.md b/docs/snap/configure-cellular-connections.md
new file mode 100644
index 0000000..215f2dc
--- /dev/null
+++ b/docs/snap/configure-cellular-connections.md
@@ -0,0 +1,124 @@
+---
+title: "Configure Cellular Connections"
+table_of_contents: False
+---
+
+# Configure Cellular Connections
+
+Check whether a modem was properly detected via:
+
+```
+$ sudo modem-manager.mmcli -L
+Found 1 modems:
+	/org/freedesktop/ModemManager1/Modem/0 [description]
+```
+
+In this case we have just one modem, with index 0 (the number at the end of the DBus object path).
+
+Show detailed information about the modem:
+
+```
+$ sudo modem-manager.mmcli -m 0
+/org/freedesktop/ModemManager1/Modem/0 (device id '871faa978a12ccb25b9fa30d15667571ab38ed88')
+  -------------------------
+  Hardware |   manufacturer: 'ZTE INCORPORATED'
+           |          model: 'MF626'
+           |       revision: 'MF626V1.0.0B06'
+           |      supported: 'gsm-umts'
+           |        current: 'gsm-umts'
+           |   equipment id: '357037039840195'
+  -------------------------
+  System   |         device: '/sys/devices/pci0000:00/0000:00:01.2/usb1/1-1'
+           |        drivers: 'option1'
+           |         plugin: 'ZTE'
+           |   primary port: 'ttyUSB3'
+           |          ports: 'ttyUSB0 (qcdm), ttyUSB1 (at), ttyUSB3 (at)'
+  -------------------------
+  Numbers  |           own : 'unknown'
+  -------------------------
+  Status   |           lock: 'sim-pin'
+           | unlock retries: 'sim-pin (3), sim-puk (10)'
+           |          state: 'locked'
+           |    power state: 'on'
+           |    access tech: 'unknown'
+           | signal quality: '0' (cached)
+  -------------------------
+  Modes    |      supported: 'allowed: any; preferred: none'
+           |        current: 'allowed: any; preferred: none'
+  -------------------------
+  Bands    |      supported: 'unknown'
+           |        current: 'unknown'
+  -------------------------
+  IP       |      supported: 'none'
+  -------------------------
+  SIM      |           path: '/org/freedesktop/ModemManager1/SIM/0'
+
+  -------------------------
+  Bearers  |          paths: 'none'
+```
+
+In this case we can see that the SIM has PIN locking enabled and its state is
+‘locked’. To enter the PIN, we need to know the SIM index, which in this
+case is 0 (it is the number at the end of /org/freedesktop/ModemManager1/SIM/0).
+Once the index is known, we can enter the SIM PIN with:
+
+```
+$ sudo modem-manager.mmcli -i 0 --pin=<PIN>
+successfully sent PIN code to the SIM
+```
+
+Some more commands for handling SIM PINs include:
+
+```
+$ sudo modem-manager.mmcli -i 0 --pin=<PIN> --enable-pin
+$ sudo modem-manager.mmcli -i 0 --pin=<PIN> --disable-pin
+$ sudo modem-manager.mmcli -i 0 --pin=<PIN> --change-pin=<NEW_PIN>
+$ sudo modem-manager.mmcli -i 0 --puk=<PUK>
+```
+
+Which respectively enables PIN locking, disables PIN locking, changes the PIN code,
+and unlocks a [PUK](https://en.wikipedia.org/wiki/Personal_unblocking_code)-locked SIM.
+
+After that we can add a cellular connection with:
+
+```
+$ nmcli c add type gsm ifname <interface> con-name <name> apn <operator_apn>
+$ nmcli r wwan on
+```
+
+where &lt;interface&gt; is the string listed as “primary port” in the output from 'sudo mmcli -m &lt;N&gt;'
+(as previously described),
+&lt;name&gt; is an arbitrary name used to identify the connection, and &lt;operator_apn&gt; is
+the APN name for your cellular data plan.  Note that &lt;interface&gt; is usually a serial
+port with pattern /dev/tty*, not a networking interface. The reason for ModemManager
+to use that instead of the networking interface is that this last one can appear/disappear
+dynamically while the ports do not if the hardware configuration remains unchanged.
+For instance, the networking interface can be ppp0, ppp1, etc., and it might be
+different each time it is possible to have other ppp connections with, say, VPNs.
+
+After executing these commands, NetworkManager will automatically try to bring up
+the cellular connection whenever ModemManager reports that the modem has
+registered (the state of the modem can be checked with the previously introduced
+command “sudo modem-manager.mmcli -m &lt;N&gt;”). When done successfully, NetworkManager
+will create routes for the new network interface, with less priority than
+Ethernet or WiFi interfaces. To disable the connection, we can do:
+
+```
+$ nmcli r wwan off
+```
+
+or change the autoconnect property and turn the connection off if we need more
+fine-grained control:
+
+```
+$ nmcli c modify <name> connection.autoconnect [yes|no]
+$ nmcli c down <name>
+```
+
+Finally, note that we can provide the PIN (so it is entered automatically) or more
+needed APN provisioning information when creating/modifying the WWAN connection.
+For instance:
+
+```
+$ nmcli c add type gsm ifname <interface> con-name <name> apn <operator_apn> username <user> password <password> pin <PIN>
+```
diff --git a/docs/snap/configure-wifi-connections.md b/docs/snap/configure-wifi-connections.md
new file mode 100644
index 0000000..4602dfd
--- /dev/null
+++ b/docs/snap/configure-wifi-connections.md
@@ -0,0 +1,80 @@
+---
+title: "Configure WiFi Connections"
+table_of_contents: True
+---
+
+# Configure WiFi Connections
+
+This section explains how to establish a WiFi connection. It covers creating and
+modyfying connections as well as directly connecting.
+
+## Establish a Wireless Connection
+
+This section will show how to establish a wifi connection to the wireles
+network. Note that directly connecting will implicitly create a connection (that
+can be seen with "nmcli c"). The naming of such will follow "SSID N" pattern,
+where N is a number.
+
+First, determine the name of the WiFi interface:
+
+```
+$ nmcli d
+DEVICE             TYPE      STATE         CONNECTION
+...
+wlan0              wifi      disconnected     --
+```
+
+Make sure the WiFi radio is on (which is its default state):
+
+```
+$ nmcli r wifi on
+```
+
+Then, list the available WiFi networks:
+
+```
+$ nmcli d wifi list
+*  SSID           MODE   CHAN  RATE       SIGNAL  BARS  SECURITY
+   ...
+   my_wifi      Infra  5     54 Mbit/s  89      ▂▄▆█  WPA2
+```
+
+As an example, to connect to the access point 'my_wifi', you would use the
+following command:
+
+```
+$ nmcli d wifi connect my_wifi password <password>
+```
+
+&lt;password&gt; is the password for the connection which needs to have 8-63
+characters or 64 hexadecimal characters to specify a full 256-bit key.
+
+## Connect to a Hidden Network
+
+A hidden network is a normal wireless network that simply does not broadcast
+it's SSID unless solicited. This means that its name cannot be searched and
+must be known from some other source.
+
+Issue the following command to create a connection associated with a hidden
+network &lt;ssid&gt;:
+
+```
+$ nmcli c add type wifi con-name <name> ifname wlan0 ssid <ssid>
+$ nmcli c modify <name> wifi-sec.key-mgmt wpa-psk wifi-sec.psk <password>
+```
+
+Now you can establish a connection by typing:
+
+```
+$ nmcli c up <name>
+```
+
+&lt;name&gt; is an arbitrary name given to the connection and &lt;password&gt;
+is the password to the network. It needs to have between 8-63 characters or 64
+hexadecimal characters in order to specify a full 256-bit key.
+
+## Further Information
+
+You will find further information and more detailed examples on following pages:
+
+* <https://developer.gnome.org/NetworkManager/unstable/nmcli.html>
diff --git a/docs/snap/edit-connections.md b/docs/snap/edit-connections.md
new file mode 100644
index 0000000..0c9d087
--- /dev/null
+++ b/docs/snap/edit-connections.md
@@ -0,0 +1,155 @@
+---
+title: "Edit Connections"
+table_of_contents: True
+---
+
+# Edit Connections
+
+This part will show you how to use a network-manager built-in editor to modify
+the connections as well as provide a reference for setting some of the
+settings.
+
+## Using nmcli Console
+
+Aside from offering the possibility to manage and modify the network connections
+using the command-line, network-manager offers a built-in, interactive
+console to achieve the same. In order to use it type:
+
+```
+$ nmcli connection edit
+```
+
+It will bring up an interactive console. In the first step you will be prompted
+to enter the connection type. The list of valid connection types will be
+displayed on the screen. Once you select one you will be taken to the nmcli
+console where you have the possibility to modify its parameters.
+
+Alternatively, if you know the valid connection types, you could jump straight
+to the nmcli console by providing the type as a parameter:
+
+```
+$ nmcli connection edit type <type>
+```
+
+where &lt;type&gt;  must be a valid connection type such as 'wifi'.
+
+An attempt to edit the wifi connection type would look like:
+
+```
+$ nmcli c edit
+
+Valid connection types: generic, 802-3-ethernet (ethernet), pppoe,
+802-11-wireless (wifi), wimax, gsm, cdma, infiniband, adsl, bluetooth, vpn,
+802-11-olpc-mesh (olpc-mesh), vlan, bond, team, bridge, bond-slave, team-slave,
+bridge-slave, no-slave, tun, ip-tunnel, macvlan, vxlan
+Enter connection type: wifi
+
+===| nmcli interactive connection editor |===
+
+Adding a new '802-11-wireless' connection
+
+Type 'help' or '?' for available commands.
+Type 'describe [<setting>.<prop>]' for detailed property description.
+
+You may edit the following settings: connection, 802-11-wireless (wifi),
+802-11-wireless-security (wifi-sec), 802-1x, ipv4, ipv6
+nmcli>
+```
+
+From now on it is possible to edit the wifi connection settings. The list of
+settings is provided as in the example above. The nmcli console offers a set of
+commands that can be used to navigate between settings. To get the list of
+available commands type 'help' or '?'
+
+```
+nmcli> ?
+------------------------------------------------------------------------------
+---[ Main menu ]---
+goto     [<setting> | <prop>]        :: go to a setting or property
+remove   <setting>[.<prop>] | <prop> :: remove setting or reset property value
+set      [<setting>.<prop> <value>]  :: set property value
+describe [<setting>.<prop>]          :: describe property
+print    [all | <setting>[.<prop>]]  :: print the connection
+verify   [all | fix]                 :: verify the connection
+save     [persistent|temporary]      :: save the connection
+activate [<ifname>] [/<ap>|<nsp>]    :: activate the connection
+back                                 :: go one level up (back)
+help/?   [<command>]                 :: print this help
+nmcli    <conf-option> <value>       :: nmcli configuration
+quit                                 :: exit nmcli
+------------------------------------------------------------------------------
+nmcli> 
+```
+
+## Change Connection Details
+
+This section will show how to change some of the connection details including
+IPv4 and IPv6 settings.
+
+It is important to understand that every option can be modified using either the
+command-line or the editor. The advantage of the editor is that it shows which
+options are availabe for modification in contrast to the command-line which does
+not.
+
+It is possible however to learn about the available settings from the
+command-line by printing the connection details. Type:
+
+```
+$ nmcli c show <name>
+```
+
+where &lt;name&gt; is the connection name.
+
+The above will bring a fairly long list of text on the terminal, therefore it is
+best to either use a pager or grep to make the results manageable.
+
+### IPv4 and IPv6 Options
+
+For example for IPv4 settings one would do:
+
+```
+$ nmcli c show <name> | grep ipv4
+ipv4.method:                            auto
+ipv4.dns:
+ipv4.dns-search:
+ipv4.dns-options:                       (default)
+ipv4.addresses:
+ipv4.gateway:                           --
+ipv4.routes:
+ipv4.route-metric:                      -1
+ipv4.ignore-auto-routes:                no
+ipv4.ignore-auto-dns:                   no
+ipv4.dhcp-client-id:                    --
+ipv4.dhcp-timeout:                      0
+ipv4.dhcp-send-hostname:                yes
+ipv4.dhcp-hostname:                     --
+ipv4.dhcp-fqdn:                         --
+ipv4.never-default:                     no
+ipv4.may-fail:                          yes
+ipv4.dad-timeout:                       -1 (default)
+```
+
+For example setting up the DNS server would require typing:
+
+```
+$ nmcli c modify <name> ipv4.dns "8.8.8.8"
+```
+
+The rest of the settings can be modified in the same fashion.
+
+### WiFi Powersave Option
+
+The WiFi powersave option can have one of the following values:
+
+| Value | Meaning                                           |
+|-------|---------------------------------------------------|
+| 0     | Default                                           |
+| 1     | Ignore, do not touch currently configured setting |
+| 2     | Disable                                           |
+| 3     | Enable                                            |
+
+Changing it is as simple as:
+
+```
+$ nmcli c modify <name> 802-11-wireless.powersave 2
+```
diff --git a/docs/snap/enable-ethernet-support.md b/docs/snap/enable-ethernet-support.md
new file mode 100644
index 0000000..1aebf45
--- /dev/null
+++ b/docs/snap/enable-ethernet-support.md
@@ -0,0 +1,38 @@
+---
+title: "Enable Ethernet Support"
+table_of_contents: False
+---
+
+# Enable Ethernet Support
+
+The default netplan configuration files in Ubuntu Core leave management of
+Ethernet devices to networkd. Therefore, to avoid conflicts, the
+network-manager snap does not manage Ethernet devices by default. The user has
+to take care to enable it after installation if desired.
+
+## Configure System for Ethernet Support
+
+Before following the instructions below, backup the contents of /etc/netplan to
+be able to restore it at a later point.
+
+Also, note that this change might lead to a system without properly configured
+network connections, which would lead to problems accessing the device, so be
+careful when doing this.
+
+To enable ethernet support, you have to set the `ethernet.enable` property to
+`true`.  See how to do this [here](reference/configuration/ethernet_support.md).
+When this is done, configuration files for netplan are created so
+network-manager is the default netplan renderer. When set to `false` (the
+default), the NM snap explicitly disables the management of ethernet devices to
+avoid conflicts with networkd.
+
+Rebooting the system will be needed for the changes to take effect.
+
+After the reboot, NetworkManager should automatically set up attached Ethernet
+ports or use existing netplan configuration files to setup connections.
+
+Once logged into the system you may check the current connection status by
+
+```
+$ nmcli c show
+```
diff --git a/docs/snap/explore-network-status.md b/docs/snap/explore-network-status.md
new file mode 100644
index 0000000..7b43950
--- /dev/null
+++ b/docs/snap/explore-network-status.md
@@ -0,0 +1,52 @@
+---
+title: "Explore Network Status"
+table_of_contents: False
+---
+
+# Exploring Network Status
+
+This section shows how to use the nmcli command-line tool to examine the status
+of NetworkManager’s connections and devices.
+
+Show the status of devices known to NetworkManager:
+
+```
+$ nmcli d
+```
+
+Show more information for this option:
+
+```
+$ nmcli d --help
+```
+
+Show the current status of each of NetworkManager’s connections:
+
+```
+$ nmcli c
+```
+
+Command “c” is for connections but is a abbreviated form of the real command
+"connections". As for the devices command, “--help” shows more information for
+this option. Finally, we can see the state of radio interfaces, including WiFi
+and WWAN (cellular) with:
+
+```
+$ nmcli r
+WIFI-HW  WIFI     WWAN-HW  WWAN    
+enabled  enabled  enabled  enabled
+```
+
+It is important to make sure that WiFi/WWAN radios are enabled so the respective
+connection types can establish a connection (we will specify how to this in
+following sections). As with the other commands, “--help” shows usage information.
+
+Observe NetworkManage activity (changes in connectivity state, devices or
+connection properties):
+
+```
+$ nmcli monitor
+```
+
+See nmcli connection monitor and nmcli device monitor to watch for changes in
+certain connections or devices.
diff --git a/docs/snap/faq.md b/docs/snap/faq.md
new file mode 100644
index 0000000..ede5b21
--- /dev/null
+++ b/docs/snap/faq.md
@@ -0,0 +1,18 @@
+---
+title: "FAQ"
+table_of_contents: False
+---
+
+# FAQ
+
+This section covers some of the most commonly encountered problems and attempts
+to provide solutions for them.
+
+## Ethernet devices are not used
+
+### Possible cause: Ethernet support is disabled for NetworkManager
+
+By default the network-manager snap disables Ethernet support to avoid conflicts
+with networkd/netplan which are used by default on Ubuntu Core 16. See
+*[Enable Ethernet Support](enable-ethernet-support.md)* for details on how to
+enable it.
diff --git a/docs/snap/index.md b/docs/snap/index.md
new file mode 100644
index 0000000..81dcc30
--- /dev/null
+++ b/docs/snap/index.md
@@ -0,0 +1,42 @@
+---
+title: "NetworkManager"
+table_of_contents: False
+---
+
+# About NetworkManager
+
+NetworkManager is a system network service that manages your network
+devices and connections, attempts to keep network connectivity active
+when available. It manages Ethernet, WiFi, mobile broadband (WWAN) and
+PPPoE devices while also providing VPN integration with a variety of
+different VPN serivces.
+
+By default network management on [Ubuntu Core](https://www.ubuntu.com/core) is
+handled by systemd's
+[networkd](https://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html)
+and [netplan](https://launchpad.net/netplan). While NetworkManager has some
+support to handle netplan configuration files, Ethernet support is disabled by
+default and has to be turned on explicitly to avoid conflicts with existing
+network configuration.
+
+## What NetworkManager Offers
+
+The upstream NetworkManager project offers a wide range of features which are
+partially available in the snap version. However,
+as the snap should be always delivered in high quality we don't have yet all
+upstream features enabled.
+
+Currently we provide support for the following high level features:
+
+ * WiFi connectivity
+ * WWAN connectivity (together with ModemManager)
+ * Ethernet connectivity
+
+ Currently we do not support the following features:
+
+  * VPN
+
+## Upstream documentation
+
+Existing documentation from the upstream project can be found
+[here](https://wiki.gnome.org/Projects/NetworkManager).
diff --git a/docs/snap/installation.md b/docs/snap/installation.md
new file mode 100644
index 0000000..b031d79
--- /dev/null
+++ b/docs/snap/installation.md
@@ -0,0 +1,62 @@
+---
+title: "Install NetworkManager"
+table_of_contents: True
+---
+
+# Install NetworkManager
+
+The NetworkManager snap is currently available from the Ubuntu Store. It can
+be installed on any system that supports snaps but is only recommended on
+[Ubuntu Core](https://www.ubuntu.com/core) at the moment.
+
+You can install the snap with the following command:
+
+```
+ $ snap install network-manager
+ network-manager 1.2.2-10 from 'canonical' installed
+```
+
+Although the network-manager snap is available from other channels (candidate, beta, edge),
+only the stable version should be used for production devices. Their meaning is internal
+to the development team of the network-manager snap.
+
+All necessary plugs and slots will be automatically connected within the
+installation process. You can verify this with:
+
+```
+$ snap interfaces network-manager
+Slot                     Plug
+:network-setup-observe   network-manager
+:ppp                     network-manager
+network-manager:service  network-manager:nmcli
+-                        network-manager:modem-manager
+```
+
+**NOTE:** The _network-manager:modem-manager_ plug only gets connected when the
+_modem-manager_ snap is installed too. Otherwise it stays disconnected.
+
+Once the installation has successfully finished the
+NetworkManager service is running in the background. You can check its current
+status with
+
+```
+ $ systemctl status snap.networkmanager
+ ● snap.networkmanager.service - Service for snap application networkmanager
+   Loaded: loaded (/etc/systemd/system/snap.networkmanager.service; enabled; vendor preset: enabled)
+   Active: active (running) since Thu 2017-02-16 09:59:39 UTC; 16s ago
+   Main PID: 1389 (networkmanager)
+   [...]
+```
+
+Now you have NetworkManager successfully installed.
+
+## Next Steps
+
+ * [Enable Ethernet Support](enable-ethernet-support.md)
+ * [Explore Network Status](explore-network-status.md)
+ * [Configure WiFi Connections](configure-wifi-connections.md)
+ * [Configure Cellular Connections](configure-cellular-connections.md)
+ * [Edit Network Connections](edit-connections.md)
+ * [Routing Tables](routing-tables.md)
+ * [Logging Messages](logging-messages.md)
+ * [Enable Debug Support](reference/snap-configuration/debug.md)
diff --git a/docs/snap/logging-messages.md b/docs/snap/logging-messages.md
new file mode 100644
index 0000000..d242808
--- /dev/null
+++ b/docs/snap/logging-messages.md
@@ -0,0 +1,43 @@
+---
+title: "Logging Messages"
+table_of_contents: False
+---
+
+# Logging Messages
+
+This section will show how to modify the logging levels by NetworkManager.
+
+NetworkManager supports on the fly changing of the logging levels and allows for
+a fine control over what is logged.
+
+First check what is the current logging setup, type:
+
+```
+$ nmcli general logging
+```
+
+As a result you will be presented with the information about the current
+configuration:
+
+```
+LEVEL  DOMAINS                                                                                                                                                                                                                 
+INFO   PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,TEAM,CONCHECK,DCB,DISPATCH,AUDIT,SYSTEMD 
+```
+
+It is possible to change the level either globally or for each domain
+separately. The command to achieve this is:
+
+```
+$ nmcli general logging [level <level> [domain <domain>]]
+```
+
+The &lt;level&gt; is the desired log level. You can choose from the following:
+
+* **ERR:** will log only critical errors
+* **WARN:** will log warnin messages
+* **INFO:** will log various informational messages
+* **DEBUG:** enables verbose logging for debugging purposes
+
+&lt;domain&gt; is the category of messages that shall be logged with given
+severity. **WIFI** will include only WiFi related messages, **IP4** will include
+only IPv4 related messages and so on..
diff --git a/docs/snap/metadata.yaml b/docs/snap/metadata.yaml
new file mode 100644
index 0000000..82bf35f
--- /dev/null
+++ b/docs/snap/metadata.yaml
@@ -0,0 +1,49 @@
+site_title: NetworkManager documentation
+site_logo_url: https://assets.ubuntu.com/v1/c5cb0f8e-picto-ubuntu.svg
+navigation:
+  - title: Introduction
+    children:
+      - title: About NetworkManager
+        location: index.md
+  - title: Install & Configure
+    children:
+      - title: Install NetworkManager
+        location: installation.md
+      - title: Explore Network Status
+        location: explore-network-status.md
+      - title: Configure WiFi Connections
+        location: configure-wifi-connections.md
+      - title: Configure Cellular Connections
+        location: configure-cellular-connections.md
+      - title: Enable Ethernet Support
+        location: enable-ethernet-support.md
+      - title: Edit Connections
+        location: edit-connections.md
+      - title: Routing Tables
+        location: routing-tables.md
+      - title: Logging Messages
+        location: logging-messages.md
+  - title: Reference
+    children:
+      - title: Snap Configuration
+        children:
+          - title: Ethernet Support
+            location: reference/configuration/ethernet_support.md
+          - title: Debug
+            location: reference/snap-configuration/debug.md
+          - title: Wake on WLAN
+            location: reference/snap-configuration/wowlan.md
+          - title: WiFi Powersave
+            location: reference/snap-configuration/wifi-powersave.md
+      - title: Available Commands
+        location: reference/available-commands.md
+      - title: DBUS API
+        location: reference/dbus-api.md
+  - title: Troubleshoot
+    children:
+      - title: FAQ
+        location: faq.md
+  - title: Release Notes
+    location: release-notes.md
+  - title: Report a Bug
+    location: report-bug.md
diff --git a/docs/snap/reference/available-commands.md b/docs/snap/reference/available-commands.md
new file mode 100644
index 0000000..18b3cec
--- /dev/null
+++ b/docs/snap/reference/available-commands.md
@@ -0,0 +1,19 @@
+---
+title: Available Commands
+table_of_contents: true
+---
+
+# Available Commands
+
+The NetworkManager upstream project comes with a few commands which can be used
+to control and manage the NetworkManager service. This page gives a short overview
+of those commands which are available as part of the snap and what they are used for.
+Further details about their usage is given on linked pages.
+
+## nmcli
+
+The nmcli command offers a command-line based way to control and manage the
+NetworkManager service.
+
+An explanatory description of the command and available options are available
+[here](https://developer.gnome.org/NetworkManager/1.2/nmcli.html)
diff --git a/docs/snap/reference/configuration/ethernet_support.md b/docs/snap/reference/configuration/ethernet_support.md
new file mode 100644
index 0000000..fbc5929
--- /dev/null
+++ b/docs/snap/reference/configuration/ethernet_support.md
@@ -0,0 +1,47 @@
+---
+title: Ethernet Support
+table_of_contents: true
+---
+
+# Ethernet Support
+
+*Available since:* 1.2.2-12
+
+The NetworkManager snap provides a configuration option to adjust
+if it should manage ethernet network connections.
+
+By default the NetworkManager snap **does not** manage ethernet network
+devices as it would conflict with the default network management in
+Ubuntu Core which is handled by [netplan](https://launchpad.net/netplan) and
+[networkd](https://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html).
+
+## Enable Ethernet Support
+
+To enable management of ethernet network devices the snap provides the
+*ethernet.enable* configuration option.
+
+This configuration option accepts the following values
+
+ * **false (default):** Ethernet support is disabled. All network
+ devices matching the expression 'en*' or 'eth*' will be ignored.
+ * **true:** All ethernet devices available on the system will be
+ managed by NetworkManager. networkd will not manage any of these
+ anymore.
+
+Changing the *ethernet* configuration option needs a reboot of the
+device it's running on.
+
+After the device has rebooted ethernet support is enabled NetworkManager will
+take over management of all available ethernet network devices on the device.
+
+NetworkManager will reuse existing configurations files from */etc/netplan*
+when ethernet support is enabled. Those will marked as immutable inside
+NetworkManager and any changes need to be written manually into the relevant
+files in */etc/netplan*.
+
+Example:
+
+```
+ $ snap set network-manager ethernet.enable=true
+ $ sudo reboot
+```
diff --git a/docs/snap/reference/dbus-api.md b/docs/snap/reference/dbus-api.md
new file mode 100644
index 0000000..7cece10
--- /dev/null
+++ b/docs/snap/reference/dbus-api.md
@@ -0,0 +1,9 @@
+---
+title: "DBUS API"
+table_of_contents: False
+---
+
+# DBUS API
+
+Documentation of the DBus API is provided by the NetworkManager upstream project
+[here](https://developer.gnome.org/NetworkManager/1.2/spec.html).
diff --git a/docs/snap/reference/snap-configuration/debug.md b/docs/snap/reference/snap-configuration/debug.md
new file mode 100644
index 0000000..e16d17c
--- /dev/null
+++ b/docs/snap/reference/snap-configuration/debug.md
@@ -0,0 +1,51 @@
+---
+title: Debug
+table_of_contents: True
+---
+
+# Debug
+
+Debug is a feature that controls the amount of logs produced by the network-manager
+snap. It is useful for collecting information required to either report a bug or
+investigate a network-manager failure (if happens).
+
+It is disabled by default and has to be explicitely turned on for usage.
+
+Note that the debug logs may contain sensitive information.
+
+## Enable Debug
+
+The network-manager snap provides a single configuration option which can be used to
+turn the debug feature either on or off:
+
+ * **debug.enable**
+
+The option takes a boolean value. The meaning of the possible values are:
+
+ * **true:** Enable logging debug information
+ * **false (default):** Disable logging debug information
+
+Changing the **debug** configuration option has immediate effect and also
+affects future executions of the NM daemon.
+
+**Example:** Enable debug feature
+
+```
+$ snap set network-manager debug.enable=true
+```
+
+<br/>
+**Example:** Disable debug feature.
+
+```
+$ snap set network-manager debug.enable=false
+```
+
+## Viewing logs
+
+The debug information, when enabled, will be available in the journal and can
+be viewed with:
+
+```
+$ journalctl --no-pager -u snap.network-manager.networkmanager.service
+```
diff --git a/docs/snap/reference/snap-configuration/wifi-powersave.md b/docs/snap/reference/snap-configuration/wifi-powersave.md
new file mode 100644
index 0000000..8b9e68f
--- /dev/null
+++ b/docs/snap/reference/snap-configuration/wifi-powersave.md
@@ -0,0 +1,38 @@
+---
+title: WiFi Powersave
+table_of_contents: True
+---
+
+# WiFi Powersave
+
+WiFi Powersave is a feature that allows a device to suspend its radio activity
+after a fixed period of inactivity. The device remains idle for a fixed time,
+usualy about 100ms, and once it is reached it wakes up to check if the
+infrastructure has any packets queued up for it.
+
+The NetworkManager snap allows to configure this option by either enabling or
+disabling the powersave feature.
+
+You can read more about the WiFi Powersave feature on the following sites:
+
+*
+<https://wireless.wiki.kernel.org/en/developers/documentation/ieee80211/power-savings>
+
+### Enable WiFi Powersave
+
+To allow users to enable or disable WiFi Powersave, the snap provides a single
+configuration option:
+
+* wifi.powersave
+
+Option can be set via the configuration API snaps provide. See
+<https://docs.ubuntu.com/core/en/guides/build-device/config-hooks> for more
+details.
+
+#### wifi.powersave
+
+This configuration option accepts the following values:
+
+* **disabled (default):** WiFi powersaving is disabled
+* **enabled:** WiFi powersaving is enabled
+
diff --git a/docs/snap/reference/snap-configuration/wowlan.md b/docs/snap/reference/snap-configuration/wowlan.md
new file mode 100644
index 0000000..2ae0791
--- /dev/null
+++ b/docs/snap/reference/snap-configuration/wowlan.md
@@ -0,0 +1,126 @@
+---
+title: Wake on WLAN
+table_of_contents: True
+---
+
+# Wake on WLAN
+
+*Available since:* 1.2.2-11
+
+Wake on WLAN (called WoWLAN in the following) is a feature which allows a device
+to be woken up from standby power states to faciliate device management. It is based
+on the well well-established standard for Wake on LAN. The functionality is not entirely
+equivalent to Wake on LAN and there are some limitations.
+
+The NetworkManager snap allows its users to configure one or more triggers to allow
+the device it operates on to be woken up remotely.
+
+An important precondition for WoWLAN to work is that your device's kernel WiFi driver
+has support for it. If it is has support for WoWLAN it may only support a subset
+of possible triggers.
+
+You can read more about the kernel side implementation on the following sites:
+
+ * <https://wireless.wiki.kernel.org/en/users/documentation/wowlan>
+
+### Enable Wake on WLAN Globally
+
+To allow users to enable or disable WoWLAN, the snap provides two configuration
+options:
+
+ * **wifi.wake-on-wlan**
+ * **wifi.wake-on-wlan-password**
+
+Both options can be set via the configuration API snaps provide. See
+<https://docs.ubuntu.com/core/en/guides/build-device/config-hooks> for more
+details.
+
+Both configuration options will affect all wireless network devices. If you
+want to change it just for a single wireless connection please have a look at
+the chapter [Per Connection Configuration](#per-connection-configuration) below.
+
+
+#### wifi.wake-on-wlan
+
+This configuration option accepts the following values:
+
+ * **disabled (default):** Wake on WLAN is disabled for all wireless network devices.
+ * **any:** Wake on WLAN is enabled and any possible trigger will cause the system to wake up.
+ * **disconnect:** If a connection to a station gets disconnected the device will be woken up.
+ * **magic:** Wake on WLAN is enabled and only a received magic packet will cause the
+ system to wake up. The magic packet has the same structure as the one
+ used for Wake on LAN. For more details see <https://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet>
+ The content of the magic packet can be extended with the
+ wifi.wake-on-wlan-password option to require the client to send a
+ specific byte sequence functioning as a password so that not anyone
+ unpriviledged can wake up the system.
+ * **gtk-rekey-failure:** A failure of a GTK rekey operation will cause the device to wake up.
+ * **4way-handshake:** Reiteration of the 4way handshake will cause the device to wake up.
+ * **rfkill-release:** Release of a rfkill will cause the device to wake up.
+ * **tcp:** Any incoming TCP packet will cause the device to wake up.
+
+Example:
+
+```
+ $ snap set network-manager wifi.wake-on-wlan=magic
+```
+
+#### wifi.wake-on-wlan-password
+
+This configuration option accepts a textual value. If specified, the value will
+be used in addition to the wireless device MAC address to function as a password
+that disallows unpriviledged actors to wake up the device.
+
+Example:
+
+```
+ $ snap set network-manager wifi.wake-on-wlan-password=MyPassword
+```
+</br>
+### Per Connection Configuration
+
+To configure WoWLAN per connection you have to use the *nmcli* utility which comes
+with the NetworkManager snap. It allows you to configure the same two options
+as the snap accepts. However, the *wifi.wake-on-wlan* option takes a numeric value
+instead of a textual one.
+
+The *wifi.wake-on-wlan* option accepts the following values (see above for a detailed
+description of each value)
+
+ * **0:** disabled
+ * **1:** Use global default configuration
+ * **2:** any
+ * **4:** disconnect
+ * **8:** magic
+ * **16:** gtk-rekey-failure
+ * **32:** 4way-handshake
+ * **128:** rfkill-release
+ * **256:** tcp
+
+The *wifi.wake-on-wlan-password* option accepts the same values as the snap
+configuration option.
+
+Example:
+
+```
+ $ nmcli c modify my-connection wifi.wake-on-wlan 2
+ $ nmcli c modify my-connection wifi.wake-on-wlan-password Test1234
+```
+</br>
+### Verify WoWLAN Configuration
+
+NetworkManager will use the kernel to configure WoWLAN on the hardware level.
+The *iw* utility provides a simple way to verify the right option is configured.
+
+If you don't have the *iw* utility on your system you can install it with the
+*wireless-tools* snap.
+
+```
+ $ snap install --devmode wireless-tools
+ $ sudo wireless-tools.iw phy phy0 wowlan show
+ WoWLAN is enabled:
+ * wake up on magic packet
+```
+
+See the help output of the *iw* command for more documentation and available
+options.
diff --git a/docs/snap/release-notes.md b/docs/snap/release-notes.md
new file mode 100644
index 0000000..8a96cee
--- /dev/null
+++ b/docs/snap/release-notes.md
@@ -0,0 +1,35 @@
+---
+title: "Release Notes"
+table_of_contents: False
+---
+
+# Release Notes
+
+The version numbers mentioned on this page correspond to those released in the
+Ubuntu snap store.
+
+You can check with the following command which version you have currently
+installed:
+
+```
+$ snap info network-manager
+name:      network-manager
+summary:   "Network management based on NeworkManager"
+publisher: canonical
+description: |
+  Network management of wired Ethernet, WiFi and mobile data connection based on
+  NetworkManager and ModemManager
+commands:
+  - nmcli
+tracking:    stable
+installed:   1.2.2-10 (73) 5MB -
+[...]
+```
+</br>
+## 1.2.2-11
+
+ * Wake-on-WLAN can be configured via snap/nmcli
+ * Automatic reconfiguration of network devices when device comes back from a
+   low power state
+ * Snap alias available for nmcli
+ * WiFi powersave is configurable via snap configuration
diff --git a/docs/snap/report-bug.md b/docs/snap/report-bug.md
new file mode 100644
index 0000000..ba02a2e
--- /dev/null
+++ b/docs/snap/report-bug.md
@@ -0,0 +1,36 @@
+---
+title: "Report a Bug"
+table_of_contents: False
+---
+
+# Report a Bug
+
+Bugs can be reported [here](https://bugs.launchpad.net/snappy-hwe-snaps/+filebug).
+
+When submitting a bug report, please attach system log coming from the journal:
+
+ * $ journalctl --no-pager > system-log
+
+And the output of the following two commands:
+
+```
+$ nmcli d
+$ nmcli c
+```
+
+It is a good idea to set the log level to DEBUG so that the verbose information
+is provided. To do this for NetworkManager please see the [Logging Messages](logging-messages.md)
+page.
+
+If there is a modem and the modem-manager snap is installed, also add the output
+of
+
+```
+$ sudo modem-manager.mmcli -m <N>
+```
+
+With being <N> the modem number as reported by
+
+```
+$ sudo modem-manager.mmcli -L
+```
diff --git a/docs/snap/routing-tables.md b/docs/snap/routing-tables.md
new file mode 100644
index 0000000..85b4ff8
--- /dev/null
+++ b/docs/snap/routing-tables.md
@@ -0,0 +1,96 @@
+---
+title: "Routing Tables"
+table_of_contents: True
+---
+
+# Routing Tables
+
+This section describes the way to setup routing table as well as it explains the
+logic used to prioritize interfaces.
+
+The routing table is stored in the kernel which merely acts upon it. The route
+itself is set by the user-space tools. There is no preference as any tool
+created for this reason will do. It can be either a DHCP client, ip command or
+route command.
+
+It is important to understand that NetworkManager changes the routing table
+whenever it creates a new connection.
+
+Routing table acts as a junction and is there to show where the different
+network subnets will be routed to. An example of a routing table is shown below.
+
+```
+$ ip route
+default via 10.0.0.1 dev wlp3s0  proto static  metric 600
+10.0.0.0/24 dev wlp3s0  proto kernel  scope link  src 10.0.0.73  metric 600
+10.0.1.0/24 dev lxcbr0  proto kernel  scope link  src 10.0.1.1
+169.254.0.0/16 dev docker0  scope link  metric 1000 linkdown
+172.17.0.0/16 dev docker0  proto kernel  scope link  src 172.17.0.1 linkdown
+192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 linkdown
+```
+
+The first column is the &lt;Destination&gt; subnet with the "default" being a
+wildcard for everything else. The "via" fragment points to the &lt;Gateway&gt;
+however when it is missing it indicates that that network is connected directly
+and instead it describes a source address.
+
+The &lt;Metric&gt; column translates to the number of hops required to reach the
+destination and is used to determine which route shall be preferred when there
+are more than one route available for a specific destination. Since it
+reassembles the concept of distance the lower it's value is the better.
+
+The &lt;Metric&gt; value can be set manually however when NetworkManager creates
+a connection the following defaults are applied:
+
+* Ethernet is preferred over WiFi
+* WiFi is preferred over WWAN
+
+# Editing the Routing Tables
+
+The routing table can be added or modified using the standard *ip* command which
+is available on Ubuntu Core.
+
+You can find more information on it on the following page:
+
+* <https://linux.die.net/man/8/ip?>
+
+Separately it is possible to modify routing information per single connection
+using the nmcli tool. The parameters such as: gateway, routes and metrics can be
+modified.
+
+The following options are responsible:
+
+```
+ipv4.gateway:
+ipv4.routes:
+ipv4.route-metric:
+
+ipv6.gateway:
+ipv6.routes:
+ipv6.route-metric:
+```
+
+These options can be modified in a following way:
+
+```
+$ nmcli connection modify <name> +ipv4.routes <destination> ipv4.gateway <gateway>
+$ nmcli connection modify <name> ipv4.route-metric <metric>
+```
+
+Where &lt;name&gt; is the connection name. You can obtain it by listing
+available connections on the system:
+
+```
+$ nmcli c show
+```
+
+&lt;destination&gt; is the destination network provided as a static IP address,
+subnet or "default". &lt;gateway&gt; is the new gateway information.
+&lt;metric&gt; is the new metric information.
+
+Note that this kind of changes can be made separately for each connection thus
+it is possible to provide a fine grained control over how the packets directed
+to different networks are routed.
+
+It is also important to understand that bringing up and down connections with
+different values set for these options is in fact changing the routing table.
diff --git a/run-tests.sh b/run-tests.sh
new file mode 100755
index 0000000..593200f
--- /dev/null
+++ b/run-tests.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+#
+# Copyright (C) 2016 Canonical Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set -ex
+
+TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/tests-extras";
+TESTS_EXTRAS_PATH="tests-extras"
+
+show_help() {
+    exec cat <<'EOF'
+Usage: run-tests.sh [OPTIONS]
+
+This is fetch & forget script and what it does is to fetch the
+tests-extras repository and execute the run-tests.sh script from
+there passing arguments as-is.
+
+When you see this message you don't have the tests-extras repository
+successfully populated in your workspace yet. Please rerun without
+specifying --help to proceed with the initial clone of the git repository.
+EOF
+}
+
+# Clone the tests-extras repository
+clone_tests_extras() {
+	echo "INFO: Fetching tests-extras scripts into $TESTS_EXTRAS_PATH ..."
+	if ! git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1; then
+		echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."
+		exit 1
+	fi
+}
+
+# Make sure the already cloned tests-extras repository is in a known and update
+# state before it is going to be used.
+restore_and_update_tests_extras() {
+	echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH"
+	cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull
+	cd -
+}
+
+# ==============================================================================
+# This is fetch & forget script and what it does is to fetch the tests-extras
+# repo and execute the run-tests.sh script from there passing arguments as-is.
+#
+# The tests-extras repository ends up checked out in the snap tree but as a
+# hidden directory which is re-used since then.
+
+# Find snap to use in the tests
+snaps=$(find . -maxdepth 1 -type f -name 'network-manager_*snap')
+while read -r snap_file; do
+    if [ -n "$snap" ]; then
+        printf "More than one snap revision in the folder\n"
+        exit 1
+    fi
+    snap=$PWD/${snap_file#*/}
+done < <(printf "%s\n" "$snaps")
+
+[ ! -d "$TESTS_EXTRAS_PATH" ] && [ "$1" = "--help" ] && show_help
+
+if [ -d "$TESTS_EXTRAS_PATH" ]; then
+	restore_and_update_tests_extras
+else
+	clone_tests_extras
+fi
+
+# Any project-specific options for test-runner should be specified in
+# .tests_config under EXTRA_ARGS
+if [ -f ".tests_config" ]; then
+    # shellcheck disable=SC1091
+    . .tests_config
+fi
+
+echo "INFO: Executing tests runner"
+# shellcheck disable=SC2086
+cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@" --snap="$snap" $EXTRA_ARGS
diff --git a/snap-common/bin/snap-config.sh b/snap-common/bin/snap-config.sh
index 1c61ddc..78f4437 100644
--- a/snap-common/bin/snap-config.sh
+++ b/snap-common/bin/snap-config.sh
@@ -119,15 +119,9 @@ _switch_debug_enable() {
     # We create/remove the file for future executions and also change
     # the logging level of the running daemon.
     if [ "$1" = "true" ]; then
-        if [ ! -f "$DEBUG_FILE" ]; then
-            touch "$DEBUG_FILE"
-            "$SNAP"/bin/nmcli-internal g log level DEBUG
-        fi
+        touch "$DEBUG_FILE"
     else
-        if [ -f "$DEBUG_FILE" ]; then
-            rm -f "$DEBUG_FILE"
-            "$SNAP"/bin/nmcli-internal g log level INFO
-        fi
+        rm -f "$DEBUG_FILE"
     fi
 }
 
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 290ab83..af5b998 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -123,15 +123,15 @@ parts:
       - --with-dhcpcd=no
       - --with-dhclient=no
       - --with-dnsmasq=no
+      - --with-iptables=/snap/$SNAPCRAFT_PROJECT_NAME/current/sbin/iptables
       - --with-systemd-journal=yes
       # from 1.10 deb:
       - --libexecdir=/usr/lib/NetworkManager
       - --with-pppd=/usr/sbin/pppd
       - --with-resolvconf=no
       #
-      # TODO: iptables & dnsmasq are used for AP mode; not
+      # TODO: dnsmasq is used for AP mode; not
       # currently supported by the snap:
-      # - --with-iptables=/sbin/iptables
       # - --with-dnsmasq=/usr/sbin/dnsmasq
       - --with-dnssec-trigger=/usr/lib/dnssec-trigger/dnssec-trigger-script
       - --with-systemdsystemunitdir=/lib/systemd/system
@@ -175,6 +175,7 @@ parts:
       # Run all tests NetworkManager ships by default
       make check
     stage-packages:
+      - iptables
       - iputils-arping
       - libasn1-8-heimdal
       - libdbus-glib-1-2
@@ -231,6 +232,7 @@ parts:
     # here are the results of the network manager build.
     filesets:
       binaries:
+        - sbin/*tables*
         - usr/bin/arping
         - usr/bin/nmcli
         - usr/bin/nmtui
@@ -258,6 +260,8 @@ parts:
         - usr/lib/*/libheimbase*
         - usr/lib/*/libheimntlm*
         - usr/lib/*/libhx509*
+        - usr/lib/*/libip4tc*
+        - usr/lib/*/libip6tc*
         # required for teamdctl
         - usr/lib/*/libjansson*
         - usr/lib/*/libkrb5*26*
@@ -273,6 +277,7 @@ parts:
         - usr/lib/*/libsasl2*
         - usr/lib/*/libteamdctl*
         - usr/lib/*/libwind*
+        - usr/lib/*/libxtables*
       unwanted:
         # We don't use dhclient so we don't need this helper
         - -usr/lib/NetworkManager/nm-dhcp-helper
diff --git a/spread.yaml b/spread.yaml
new file mode 100644
index 0000000..83abb24
--- /dev/null
+++ b/spread.yaml
@@ -0,0 +1,85 @@
+#
+# Copyright (C) 2015, 2016 Canonical Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+project: network-manager
+
+environment:
+    PROJECT_PATH: /home/network-manager
+    TESTSLIB: $PROJECT_PATH/tests/lib
+    SNAP_NAME: network-manager
+    # Allow the host to pass the channel to use for the test run
+    SNAP_CHANNEL: $(HOST:echo $SNAP_CHANNEL)
+
+backends:
+    qemu:
+        systems:
+            - ubuntu-core-16:
+                username: test
+                password: test
+
+# Put this somewhere where we have read-write access
+path: /home/network-manager
+
+exclude:
+  - .git
+
+prepare: |
+  . $TESTSLIB/prepare-all.sh
+
+prepare-each: |
+  # Cleanup logs so we can just dump what has happened in the debug-each
+  # step below after a test case ran.
+  journalctl --rotate
+  sleep .1
+  journalctl --vacuum-time=1ms
+  dmesg -c > /dev/null
+
+debug-each: |
+  journalctl
+  dmesg | grep DENIED || true
+
+# Default is 15 min but we use a higher one here as we build the entire
+# network-manager snap inside the global prepare step so we need quite
+# some time. Once we can reuse artifacts from other builds we can change
+# this back to the default.
+kill-timeout: 30m
+
+suites:
+    tests/main/:
+        summary: Full-system tests for NetworkManager without ethernet support
+        systems:
+            - ubuntu-core-16
+        prepare: |
+            . $TESTSLIB/prepare.sh
+        restore-each: |
+            . $TESTSLIB/restore-each.sh
+    tests/full/:
+        summary: Full-system tests for NetworkManager being the only network management service
+        systems:
+            - ubuntu-core-16
+        prepare: |
+            . $TESTSLIB/utilities.sh
+            stop_after_first_reboot
+            switch_netplan_to_network_manager
+            . $TESTSLIB/prepare.sh
+            REBOOT
+        restore-each: |
+            . $TESTSLIB/restore-each.sh
+        restore: |
+            . $TESTSLIB/utilities.sh
+            stop_after_first_reboot
+            switch_netplan_to_networkd
+            REBOOT
diff --git a/tests/full/immutable-netplan-config/task.yaml b/tests/full/immutable-netplan-config/task.yaml
new file mode 100644
index 0000000..c218478
--- /dev/null
+++ b/tests/full/immutable-netplan-config/task.yaml
@@ -0,0 +1,10 @@
+summary: Verify that netplan configuration files are immutable
+
+execute: |
+    # Ensure we're using a configuration generated from netplan
+    test -e /etc/netplan/00-snapd-config.yaml
+    test -e /run/NetworkManager/system-connections/netplan-eth0
+
+    /snap/bin/network-manager.nmcli c | MATCH 'netplan.eth0.*eth0'
+    # Try to change the DNS server used on this connection
+    test ! `/snap/bin/network-manager.nmcli c modify netplan-eth0 ipv4.dns 8.8.8.8`
diff --git a/tests/full/ipv6-address-assignment/task.yaml b/tests/full/ipv6-address-assignment/task.yaml
new file mode 100644
index 0000000..e36ef00
--- /dev/null
+++ b/tests/full/ipv6-address-assignment/task.yaml
@@ -0,0 +1,27 @@
+summary: Verify NetworkManager can assign a static IPv6 address to an interface
+
+restore: |
+    # Ensure that the created virtual network interfaces are removed
+    # in any case when we're done
+    if [ -e /sys/class/net/veth0 ] ; then
+        ip link delete veth0
+    fi
+
+execute: |
+    . $TESTSLIB/utilities.sh
+
+    # Ensure that we have IPv6 support enabled in the kernel
+    test -e /proc/net/if_inet6
+
+    ip link add dev veth0 type veth peer name veth1
+
+    wait_for_network_manager
+
+    connection=veth-ipv6
+    /snap/bin/network-manager.nmcli c add con-name $connection ifname veth0 type ethernet \
+        ip6 abbe::cafe
+    /snap/bin/network-manager.nmcli c up $connection
+
+    # Verify that NetworkManager assigned the correct IPv6 address
+    # to the interface
+    ifconfig veth0 | grep 'abbe::cafe/128'
diff --git a/tests/full/ipv6-router-advertisements/task.yaml b/tests/full/ipv6-router-advertisements/task.yaml
new file mode 100644
index 0000000..4af402b
--- /dev/null
+++ b/tests/full/ipv6-router-advertisements/task.yaml
@@ -0,0 +1,70 @@
+summary: Test IPv6 address assignment via router advertisements
+
+restore: |
+    # Ensure that the created virtual network interfaces are removed
+    # in any case when we're done
+    if [ -e /sys/class/net/veth0 ] ; then
+        ip link delete veth0
+    fi
+
+execute: |
+    . $TESTSLIB/utilities.sh
+
+    # Ensure that we have IPv6 support enabled in the kernel
+    test -e /proc/net/if_inet6
+
+    snap install --devmode se-test-tools
+    snap connect se-test-tools:home core
+    snap connect se-test-tools:network-control core
+
+    # Create virtual ethernet interface pair
+    sudo ip link add dev veth0 type veth peer name veth1
+
+    # As the virtual ethernet devices don't get IPv6 setup
+    # correctly by default we have to do this
+    sudo sysctl -w net.ipv6.conf.veth0.disable_ipv6=0
+    sudo sysctl -w net.ipv6.conf.veth1.disable_ipv6=0
+    veth0_lla=$(mac_to_ipv6 `cat /sys/class/net/veth0/address`)
+    veth1_lla=$(mac_to_ipv6 `cat /sys/class/net/veth1/address`)
+
+    # The radvd daemon will send out router advertisements on veth1
+    # so that we can receive them on veth0 end
+    cat <<-EOF > /home/test/radvd.conf
+    interface veth1 {
+        AdvSendAdvert on;
+        prefix 2001:db8:1:2::/64 {};
+    };
+    EOF
+
+    # To ensure that nobody touches veth1 we tell NetworkManager
+    # explicitly to do that.
+    /snap/bin/network-manager.nmcli d set veth1 managed no
+
+    # Assign our link-local addresses
+    if ! ip addr show dev veth0 | grep 'inet6.*scope link.*' ; then
+        sudo ip addr add dev veth0 scope link $veth0_lla
+    fi
+    if ! ip addr show dev veth1 | grep 'inet6.*scope link.*' ; then
+        sudo ip addr add dev veth1 scope link $veth1_lla
+    fi
+
+    # This will get our router advertisement daemon started and we
+    # now configure NetworkManager
+    sudo se-test-tools.radvd -C /home/test/radvd.conf -n -d 5 -m stderr -p /home/test/radvd.pid &
+
+    # Give things a bit more time to settle
+    sleep 10
+    ip addr show dev veth0
+
+    # At this point veth0 should have now a global IPv6 address
+    # assigned via router advertisements
+    ip addr show dev veth0 | grep 'inet6 2001:db8:1:2:.*/64 scope global'
+    # but veth1 should not have any
+    ip addr show dev veth1 | grep -v 'inet6.*scope global'
+
+    # NetworkManager should report the same addresses for IPv6
+    /snap/bin/network-manager.nmcli d show veth0 | grep 'GENERAL.STATE.*connected'
+    /snap/bin/network-manager.nmcli d show veth0 | grep 'IP6.ADDRESS.*2001:db8:1:2.*/64'
+
+    # Stop the radvd daemon
+    kill -TERM `cat /home/test/radvd.pid`
diff --git a/tests/full/system-network-is-active/task.yaml b/tests/full/system-network-is-active/task.yaml
new file mode 100644
index 0000000..22d7830
--- /dev/null
+++ b/tests/full/system-network-is-active/task.yaml
@@ -0,0 +1,9 @@
+summary: Ethernet network should be managed by NetworkManager
+
+execute: |
+    . $TESTSLIB/utilities.sh
+    # Verify NetworManager handles ethernet and marks it as connected
+    test -e /etc/netplan/00-default-nm-renderer.yaml
+    wait_for_network_manager
+    /snap/bin/network-manager.nmcli d | grep 'eth0.*connected'
+    networkctl status eth0 | grep unmanaged
diff --git a/tests/lib/prepare-all.sh b/tests/lib/prepare-all.sh
new file mode 100644
index 0000000..fa8fb6b
--- /dev/null
+++ b/tests/lib/prepare-all.sh
@@ -0,0 +1,63 @@
+#!/bin/bash -x
+
+# Create a service to get the mac80211_hwsim driver loaded on system
+# startup so that we don't need to load it again in our tests as
+# load/unload multiple times in a running system can lead to kernel
+# crashes.
+cat << EOF > /etc/systemd/system/load-mac80211-hwsim.service
+[Unit]
+Description=Load mac8022_hwsim driver
+[Service]
+ExecStart=/sbin/modprobe mac80211_hwsim radios=2
+[Install]
+WantedBy=multi-user.target
+EOF
+
+systemctl enable load-mac80211-hwsim
+systemctl start load-mac80211-hwsim
+
+# We don't have to build a snap when we should use one from a
+# channel
+if [ -n "$SNAP_CHANNEL" ] ; then
+	exit 0
+fi
+
+# If there is a network-manager snap prebuilt for us, lets take
+# that one to speed things up.
+if [ -f /writable/system-data/network-manager_*_amd64.snap ]; then
+    mv /writable/system-data/network-manager_*_amd64.snap /home/network-manager/
+fi
+if [ -f /home/network-manager/network-manager_*_amd64.snap ] ; then
+	exit 0
+fi
+
+# Setup classic snap and build the network-manager snap in there
+snap install --devmode --beta classic
+cat <<-EOF > /home/test/build-snap.sh
+#!/bin/sh
+set -ex
+
+export DEBIAN_FRONTEND=noninteractive
+
+# FIXME: Enable propose for now until problems with conflicting systemd
+# packages between the Ubuntu Core image ppa and the archive are fixed.
+echo "deb http://archive.ubuntu.com/ubuntu/ xenial-proposed restricted main universe" > /etc/apt/sources.list.d/ubuntu-proposed.list
+echo "deb http://ppa.launchpad.net/snappy-dev/image/ubuntu xenial main" > /etc/apt/sources.list.d/ubuntu-image-ppa.list
+
+
+# Ensure we have the latest updates installed as the core snap
+# may be a bit out of date.
+apt update
+apt -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade -y --force-yes
+
+apt install -y --force-yes snapcraft
+cd /home/network-manager
+snapcraft clean
+snapcraft
+EOF
+chmod +x /home/test/build-snap.sh
+sudo classic /home/test/build-snap.sh
+snap remove classic
+
+# Make sure we have a snap build
+test -e /home/network-manager/network-manager_*_amd64.snap
diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
new file mode 100644
index 0000000..6565405
--- /dev/null
+++ b/tests/lib/prepare.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+. $TESTSLIB/utilities.sh
+
+echo "Wait for firstboot change to be ready"
+while ! snap changes | grep -q "Done"; do
+	snap changes || true
+	snap change 1 || true
+	sleep 1
+done
+
+echo "Ensure fundamental snaps are still present"
+. $TESTSLIB/snap-names.sh
+for name in $gadget_name $kernel_name $core_name; do
+	if ! snap list | grep -q $name ; then
+		echo "Not all fundamental snaps are available, all-snap image not valid"
+		echo "Currently installed snaps:"
+		snap list
+		exit 1
+	fi
+done
+
+# Remove any existing state archive from other test suites
+rm -f /home/network-manager/snapd-state.tar.gz
+rm -f /home/network-manager/nm-state.tar.gz
+
+# TODO install from stable once NM 1.10 is released there
+snap_install network-manager --channel=1.10/beta
+
+# Snapshot of the current snapd state for a later restore
+systemctl stop snapd.service snapd.socket
+tar czf $SPREAD_PATH/snapd-state.tar.gz /var/lib/snapd /etc/netplan
+systemctl start snapd.socket
+
+# Make sure the original netplan configuration is applied and active
+# (we do this before re-starting NM to avoid race conditions in some tests)
+netplan generate
+netplan apply
+
+# And also snapshot NetworkManager's state
+systemctl stop snap.network-manager.networkmanager
+tar czf $SPREAD_PATH/nm-state.tar.gz /var/snap/network-manager
+systemctl start snap.network-manager.networkmanager
+
+# For debugging dump all snaps and connected slots/plugs
+snap list
+snap interfaces
diff --git a/tests/lib/restore-each.sh b/tests/lib/restore-each.sh
new file mode 100644
index 0000000..b8cdac1
--- /dev/null
+++ b/tests/lib/restore-each.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+. $TESTSLIB/snap-names.sh
+. $TESTSLIB/utilities.sh
+
+# Remove all snaps not being the core, gadget, kernel or snap we're testing
+for snap in /snap/*; do
+	snap="${snap:6}"
+	case "$snap" in
+		"bin" | "$gadget_name" | "$kernel_name" | core* | "$SNAP_NAME" )
+			;;
+		*)
+			snap remove "$snap"
+			;;
+	esac
+done
+
+# Drop any generated or modified netplan configuration files. The original
+# ones will be restored below.
+rm -f /etc/netplan/*
+
+# Ensure we have the same state for snapd as we had before
+systemctl stop snapd.service snapd.socket
+rm -rf /var/lib/snapd/*
+tar xzf $SPREAD_PATH/snapd-state.tar.gz -C /
+rm -rf /root/.snap
+systemctl start snapd.service snapd.socket
+wait_for_systemd_service snapd.service
+wait_for_systemd_service snapd.socket
+
+# Make sure the original netplan configuration is applied and active
+# (we do this before re-starting NM to avoid race conditions in some tests)
+netplan generate
+netplan apply
+
+systemctl stop snap.network-manager.networkmanager
+rm -rf /var/snap/network-manager/*
+tar xzf $SPREAD_PATH/nm-state.tar.gz -C /
+systemctl start snap.network-manager.networkmanager
+wait_for_network_manager
diff --git a/tests/lib/snap-names.sh b/tests/lib/snap-names.sh
new file mode 100644
index 0000000..f15b09a
--- /dev/null
+++ b/tests/lib/snap-names.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+gadget_name=$(snap list | sed -n 's/^\(pc\|pi[23]\|dragonboard\) .*/\1/p')
+kernel_name=$gadget_name-kernel
+core_name=$(snap list | awk '/^(ubuntu-)?core / {print $1; exit}')
+if [ "$kernel_name" = "pi3-kernel" ] ; then
+	kernel_name=pi2-kernel
+fi
diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
new file mode 100644
index 0000000..6144a89
--- /dev/null
+++ b/tests/lib/utilities.sh
@@ -0,0 +1,166 @@
+#!/bin/sh
+
+snap_install() {
+	name=$1
+	if [ -n "$SNAP_CHANNEL" ] ; then
+		# Don't reinstall if we have it installed already
+		if ! snap list | grep $name ; then
+			snap install --$SNAP_CHANNEL $name
+		fi
+	else
+		# Need first install from store to get all necessary assertions into
+		# place. Second local install will then bring in our locally built
+		# snap.
+		snap install $name $2
+		snap install --dangerous $PROJECT_PATH/$name*_amd64.snap
+	fi
+}
+
+switch_netplan_to_network_manager() {
+	if [ -e /etc/netplan/00-default-nm-renderer.yaml ] ; then
+		return 0
+	fi
+
+	# set 'defaultrenderer' in case the snap is already installed
+	if snap list | grep -q network-manager ; then
+		snap set network-manager defaultrenderer=true
+		# Leave some time for NM wrapper to write netplan config
+		repeat_until_done "test -e /etc/netplan/00-default-nm-renderer.yaml"
+	else
+		cat << EOF > /etc/netplan/00-default-nm-renderer.yaml
+network:
+  renderer: NetworkManager
+EOF
+	fi
+}
+
+switch_netplan_to_networkd() {
+	if [ ! -e /etc/netplan/00-default-nm-renderer.yaml ] ; then
+		return 0
+	fi
+
+	# unset 'defaultrenderer' in case the snap is already installed
+	if snap list | grep -q network-manager ; then
+		snap set network-manager defaultrenderer=false
+		# Leave some time for NM wrapper to remove netplan config
+		repeat_until_done "test ! -e /etc/netplan/00-default-nm-renderer.yaml"
+	else
+		rm /etc/netplan/00-default-nm-renderer.yaml
+	fi
+}
+
+# waits for a service to be active. Besides that, waits enough
+# time after detecting it to be active to prevent restarting
+# same service too quickly several times.
+# $1 service name
+# $2 start limit interval in seconds (default set to 10. Exec `systemctl show THE_SERVICE -p StartLimitInterval` to verify)
+# $3 start limit burst. Times allowed to start the service in start_limit_interval time (default set to 5. Exec `systemctl show THE_SERVICE -p StartLimitBurst` to verify)
+wait_for_systemd_service() {
+	while ! systemctl status $1 ; do
+		sleep 1
+	done
+  # As debian services default limit is to allow 5 restarts in a 10sec period
+  # (StartLimitInterval=10000000 and StartLimitBurst=5), having enough wait time we
+  # prevent "service: Start request repeated too quickly" error.
+  #
+  # You can check those values for certain service by typing:
+  #   $systemctl show THE_SERVICE -p StartLimitInterval,StartLimitBurst
+  #
+  if [ $# -ge 2 ]; then
+    start_limit_interval = $2
+  else
+    start_limit_interval=$(systemctl show $1 -p StartLimitInterval | sed 's/StartLimitInterval=//')
+    # original limit interval is provided in microseconds.
+    start_limit_interval=$((start_limit_interval / 1000000))
+  fi
+
+  if [ $# -eq 3 ]; then
+    start_limit_burst = $3
+  else
+    start_limit_burst=$(systemctl show $1 -p StartLimitBurst | sed 's/StartLimitBurst=//')
+  fi
+
+  # adding 1 to be sure we exceed the limit
+  sleep_time=$((1 + $start_limit_interval / $start_limit_burst))  
+	sleep $sleep_time
+}
+
+wait_for_network_manager() {
+	wait_for_systemd_service snap.network-manager.networkmanager
+}
+
+stop_after_first_reboot() {
+	if [ $SPREAD_REBOOT -gt 0 ] ; then
+		exit 0
+	fi
+}
+
+mac_to_ipv6() {
+  mac=$1
+  ipv6_address=fe80::$(printf %02x $((0x${mac%%:*} ^ 2)))
+  mac=${mac#*:}
+  ipv6_address=$ipv6_address${mac%:*:*:*}ff:fe
+  mac=${mac#*:*:}
+  ipv6_address=$ipv6_address${mac%:*}${mac##*:}
+  echo $ipv6_address
+}
+
+# Creates an AP using wifi-ap
+# $1: SSID name
+# $2: Passphrase. If present, AP will use WPA2, otherwise it will be open.
+create_ap() {
+  if [ $# -lt 1 ]; then
+    echo "Not enough arguments for $0"
+    return 1
+  fi
+
+  snap install wifi-ap
+  # wifi-ap needs a bit of time to settle down
+  repeat_until_done 'wifi-ap.status | MATCH "ap.active: true"' 0.5
+
+  /snap/bin/wifi-ap.config set wifi.interface=wlan0
+  /snap/bin/wifi-ap.config set wifi.ssid="$1"
+  if [ $# -ge 2 ]; then
+    /snap/bin/wifi-ap.config set wifi.security=wpa2
+    /snap/bin/wifi-ap.config set wifi.security-passphrase="$2"
+  else
+    /snap/bin/wifi-ap.config set wifi.security=open
+  fi
+
+  # NM some times still detects the wifi as WPA2 instead of open, so we need
+  # to re-start to force it to refresh. See LP: #1704085. Before that, we have
+  # to wait to make sure the AP sends the beacon frames so wpa_supplicant
+  # detects the AP changes and reports the right environment to the new NM
+  # instance.
+  sleep 30
+
+  systemctl restart snap.network-manager.networkmanager.service
+  repeat_until_done "busctl status org.freedesktop.NetworkManager &> /dev/null" 0.5
+
+  repeat_until_done "network-manager.nmcli d wifi | MATCH $1" 5
+}
+
+# $1 instruction to execute repeatedly until complete or max times
+# $2 sleep time between retries. Default 1sec
+# $3 max_iterations. Default 20
+repeat_until_done() {
+  timeout=1
+  if [ $# -ge 2 ]; then
+    timeout=$2
+  fi
+
+  max_iterations=20
+  if [ $# -ge 3 ]; then
+    max_iterations=$3
+  fi
+
+  i=0
+  while [ $i -lt $max_iterations ] ; do
+      if $(eval $1) ; then
+          break
+      fi
+      sleep $timeout
+      let i=i+1
+  done
+  test $i -lt $max_iterations
+}
diff --git a/tests/main/aliases/task.yaml b/tests/main/aliases/task.yaml
new file mode 100644
index 0000000..1ae0e05
--- /dev/null
+++ b/tests/main/aliases/task.yaml
@@ -0,0 +1,13 @@
+summary: Verify aliases provided by the snap are correctly enabled
+
+execute: |
+    # FIXME: Aliases should be not in place automatically unless we
+    # have them approved from the store in our snap-declaration assertion.
+    test ! -e /snap/bin/nmcli
+
+    snap alias $SNAP_NAME.nmcli nmcli
+
+    test -e /snap/bin/nmcli
+
+    # Verify the alias works without any problems
+    /snap/bin/nmcli g
diff --git a/tests/main/can-exec-iptables/task.yaml b/tests/main/can-exec-iptables/task.yaml
new file mode 100644
index 0000000..eeffe75
--- /dev/null
+++ b/tests/main/can-exec-iptables/task.yaml
@@ -0,0 +1,11 @@
+summary: Verify the NetworkManager snap is allowed to modify the iptables firewall configuration
+
+execute: |
+    # Running a simple command in the runtime environment of our service
+    # binary will tell us if we're allowed to execute the iptables binary
+    # from the core snap or not.
+    snap run --shell network-manager.networkmanager <<EOF
+    set -ex
+    export LD_LIBRARY_PATH=/snap/network-manager/current/lib:/snap/network-manager/current/usr/lib:/snap/network-manager/current/lib/$(arch)-linux-gnu:/snap/network-manager/current/usr/lib/$(arch)-linux-gnu:/snap/network-manager/current/usr/lib/NetworkManager
+    /snap/network-manager/current/sbin/iptables -L
+    EOF
diff --git a/tests/main/debug-config-option/task.yaml b/tests/main/debug-config-option/task.yaml
new file mode 100644
index 0000000..54122ac
--- /dev/null
+++ b/tests/main/debug-config-option/task.yaml
@@ -0,0 +1,19 @@
+summary: Test network-manager snap debug configuration
+
+execute: |
+    . $TESTSLIB/utilities.sh
+
+    test "$(snap get network-manager debug.enable)" = "false"
+    ! journalctl --no-pager -u snap.network-manager.networkmanager.service | MATCH "<debug>"
+
+    snap set network-manager debug.enable=true
+    test "$(snap get network-manager debug.enable)" = "true"
+    # NM will create the file after being re-started by the hook, wait a bit
+    repeat_until_done "test -e /var/snap/network-manager/current/.debug_enabled" 5
+    network-manager.nmcli g log | MATCH "^DEBUG"
+
+    snap set network-manager debug.enable=false
+    test "$(snap get network-manager debug.enable)" = "false"
+    # NM will create the file after being re-started by the hook, wait a bit
+    repeat_until_done "test ! -e /var/snap/network-manager/current/.debug_enabled" 5
+    network-manager.nmcli g log | MATCH "^INFO"
diff --git a/tests/main/documentation-builds/task.yaml b/tests/main/documentation-builds/task.yaml
new file mode 100644
index 0000000..fd2a358
--- /dev/null
+++ b/tests/main/documentation-builds/task.yaml
@@ -0,0 +1,14 @@
+summary: Verify the project documentation is building without errors
+
+execute: |
+    # Need to install in devmode as otherwise the snap can't access our project
+    # home which is outside of the home directory of our current user.
+    snap install --devmode documentation-builder
+
+    outdir=$PROJECT_PATH/docs/snap/build
+
+    cd $PROJECT_PATH/docs/snap
+    /snap/bin/documentation-builder --output-path $outdir
+
+    # Ensure we have some files in the output directory
+    test `find $outdir -type f | wc -l` -gt 0
diff --git a/tests/main/ethernet-managed-by-networkd/task.yaml b/tests/main/ethernet-managed-by-networkd/task.yaml
new file mode 100644
index 0000000..d7bddaa
--- /dev/null
+++ b/tests/main/ethernet-managed-by-networkd/task.yaml
@@ -0,0 +1,10 @@
+summary: When no specific configuration is in place NM manages ethernet
+
+execute: |
+    . $TESTSLIB/utilities.sh
+    # Whenever we can call netplan from the NM snap, the following line won't
+    # be needed
+    systemctl restart systemd-networkd
+    networkctl | grep 'eth0.*unmanaged'
+    wait_for_network_manager
+    /snap/bin/network-manager.nmcli d | grep 'eth0.*connected'
diff --git a/tests/main/installation/task.yaml b/tests/main/installation/task.yaml
new file mode 100644
index 0000000..bdaf48d
--- /dev/null
+++ b/tests/main/installation/task.yaml
@@ -0,0 +1,17 @@
+summary: Test network-manager snap installation was successful
+
+execute: |
+    . $TESTSLIB/utilities.sh
+
+    # Service should be up an running
+    wait_for_network_manager
+
+    # .. and nmcli should be able to reach NetworkManager
+    /snap/bin/network-manager.nmcli g
+
+    # Ensure all necessary plugs/slots are connected
+    snap interfaces | grep -Pzq ":network-setup-observe +[a-z,-]*network-manager"
+    snap interfaces | grep -Pzq ":ppp +[a-z,-]*network-manager"
+    snap interfaces | grep -Pzq ":firewall-control +[a-z,-]*network-manager"
+    snap interfaces | grep -Pzq ":network-setup-observe +[a-z,-]*network-manager"
+    snap interfaces | grep -Pzq "network-manager:service +network-manager:nmcli"
diff --git a/tests/main/set-hostname/task.yaml b/tests/main/set-hostname/task.yaml
new file mode 100644
index 0000000..69b27c8
--- /dev/null
+++ b/tests/main/set-hostname/task.yaml
@@ -0,0 +1,17 @@
+summary: Verify we can modify the hostname of the system
+
+execute: |
+    . "$TESTSLIB/utilities.sh"
+
+    wait_for_network_manager
+
+    # Print out current hostname for nm and hostnamed to have a reference
+    # for debugging later.
+    /snap/bin/network-manager.nmcli general hostname
+    hostnamectl
+
+    expected_hostname=foobar
+    /snap/bin/network-manager.nmcli general hostname $expected_hostname
+    test "`/snap/bin/network-manager.nmcli general hostname`" = "$expected_hostname"
+    test "`hostnamectl status | grep Static`" = "   Static hostname: $expected_hostname"
+    test "`hostname`" = "$expected_hostname"
diff --git a/tests/main/static-ip-configuration/task.yaml b/tests/main/static-ip-configuration/task.yaml
new file mode 100644
index 0000000..6c86dda
--- /dev/null
+++ b/tests/main/static-ip-configuration/task.yaml
@@ -0,0 +1,49 @@
+summary: Test static IP configuration
+
+restore: |
+    # Ensure that the created virtual network interfaces are removed
+    # in any case when we're done
+    if [ -e /sys/class/net/veth0 ] ; then
+        ip link delete veth0
+    fi
+
+execute: |
+    . $TESTSLIB/utilities.sh
+
+    ip link add dev veth0 type veth peer name veth1
+
+    wait_for_network_manager
+    # NetworkManager should ignore the other side of our pipe so
+    # that we can configure it statically.
+    /snap/bin/network-manager.nmcli d set veth1 managed no
+    ip addr add 10.0.1.1/24 dev veth1
+
+    connection=veth0-static
+    /snap/bin/network-manager.nmcli c add con-name $connection type ethernet ifname veth0 \
+        ip4 10.0.1.2/24
+    /snap/bin/network-manager.nmcli c up $connection
+    /snap/bin/network-manager.nmcli d | grep 'veth0.*connected'
+
+    # Address should be correctly applied now
+    expected_veth0_address="10.0.1.2/24"
+    /snap/bin/network-manager.nmcli -m multiline -f IP4.ADDRESS c show veth0-static | grep $expected_veth0_address
+    ip addr show dev veth0 | grep 'UP'
+    ip addr show dev veth0 | grep $expected_veth0_address
+
+    # Routing needs to be in place as well
+    expected_veth0_route="10.0.1.0/24 dev veth0  proto kernel  scope link  src 10.0.1.2  metric 101"
+    ip route | grep "$expected_veth0_route"
+
+    # Disable connection and ensure IP configuration is removed
+    /snap/bin/network-manager.nmcli c down $connection
+    ip addr show dev veth0 | grep -v $expected_veth0_address
+    ip route | grep -v "$expected_veth0_route"
+
+    # Enabling network connection again and removing it should remove
+    # the IP configuration too
+    /snap/bin/network-manager.nmcli c up $connection
+    ip addr show dev veth0 | grep $expected_veth0_address
+    ip route | grep "$expected_veth0_route"
+    /snap/bin/network-manager.nmcli c delete $connection
+    ip addr show dev veth0 | grep -v $expected_veth0_address
+    ip route | grep -v "$expected_veth0_route"
diff --git a/tests/main/wifi-connect-secured-ap/task.yaml b/tests/main/wifi-connect-secured-ap/task.yaml
new file mode 100644
index 0000000..46c2ba6
--- /dev/null
+++ b/tests/main/wifi-connect-secured-ap/task.yaml
@@ -0,0 +1,14 @@
+summary: Test connection to a secured WiFi AP
+
+environment:
+    WIFI_SSID: Ubuntu
+    WIFI_PASSPHRASE: Test1234
+
+execute: |
+    . $TESTSLIB/utilities.sh
+
+    create_ap "$WIFI_SSID" "$WIFI_PASSPHRASE"
+
+    # Connect to the AP and ensure the connection was established
+    /snap/bin/network-manager.nmcli d wifi connect $WIFI_SSID password $WIFI_PASSPHRASE
+    /snap/bin/network-manager.nmcli d | grep 'wlan1.*connected'
diff --git a/tests/main/wifi-powersave-config-option/task.yaml b/tests/main/wifi-powersave-config-option/task.yaml
new file mode 100644
index 0000000..621256e
--- /dev/null
+++ b/tests/main/wifi-powersave-config-option/task.yaml
@@ -0,0 +1,31 @@
+summary: Verify WiFi powersave can be enabled via a snap config option
+
+environment:
+    WIFI_POWERSAVE_CONF_PATH: /var/snap/network-manager/current/conf.d/wifi-powersave.conf
+
+execute: |
+    . $TESTSLIB/utilities.sh
+
+    # The mac80211_hwsim driver does not support the powersave mode
+    # so we can't check this reliable.
+
+    test "`snap get network-manager wifi.powersave`" = "disabled"
+    grep "wifi.powersave = 2" $WIFI_POWERSAVE_CONF_PATH
+
+    # Try to enable and disable again
+    snap set network-manager wifi.powersave=enabled
+    wait_for_network_manager
+    test "`snap get network-manager wifi.powersave`" = "enabled"
+    grep "wifi.powersave = 3" $WIFI_POWERSAVE_CONF_PATH
+
+    snap set network-manager wifi.powersave=disabled
+    wait_for_network_manager
+    test "`snap get network-manager wifi.powersave`" = "disabled"
+    grep "wifi.powersave = 2" $WIFI_POWERSAVE_CONF_PATH
+
+    # Specifying no value means the snap should use the default
+    # which is 'disable'
+    snap set network-manager wifi.powersave=
+    wait_for_network_manager
+    test "`snap get network-manager wifi.powersave`" = "disabled"
+    grep "wifi.powersave = 2" $WIFI_POWERSAVE_CONF_PATH
diff --git a/tests/main/wifi-wowlan-config-option/task.yaml b/tests/main/wifi-wowlan-config-option/task.yaml
new file mode 100644
index 0000000..a0e1e0b
--- /dev/null
+++ b/tests/main/wifi-wowlan-config-option/task.yaml
@@ -0,0 +1,77 @@
+summary: Verify WiFi WoWLAN can be enabled via a snap config option
+
+environment:
+    WIFI_WOWL_CONF_PATH: /var/snap/network-manager/current/conf.d/wifi-wowlan.conf
+
+execute: |
+    . $TESTSLIB/utilities.sh
+
+    # The mac80211_hwsim driver does not support WoWLAN so we can't
+    # check this reliable on the hardware level and will only check
+    # in the following that the correct configuration for
+    # NetworkManager itself is written out.
+
+    test `snap get network-manager wifi.wake-on-wlan` = disabled
+    grep "^wifi.wake-on-wlan=0$" $WIFI_WOWL_CONF_PATH
+
+    test "`snap get network-manager wifi.wake-on-wlan-password`" = ""
+    grep -v "^wifi.wake-on-wlan-password=.*$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan-password=Test1234
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan-password=Test1234$" $WIFI_WOWL_CONF_PATH
+    # Setting the password alone should keep the actual WoWLAN value
+    # still unset so that NetworkManager uses its default.
+    grep -v "^wifi.wake-on-wlan=.*$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=magic
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=8$" $WIFI_WOWL_CONF_PATH
+    grep "^wifi.wake-on-wlan-password=Test1234$" $WIFI_WOWL_CONF_PATH
+
+    # Test all other possible keys for the wifi.wake-on-wlan option
+    snap set network-manager wifi.wake-on-wlan=disabled
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=0$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=any
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=2$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=disconnect
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=4$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=magic
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=8$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=gtk-rekey-failure
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=16$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=eap-identity-request
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=32$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=4way-handshake
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=64$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=rfkill-release
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=128$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=tcp
+    wait_for_network_manager
+    grep "^wifi.wake-on-wlan=256$" $WIFI_WOWL_CONF_PATH
+
+    # Not setting any concrete value should remove the configuration
+    snap set network-manager wifi.wake-on-wlan-password=
+    wait_for_network_manager
+    grep -v "^wifi.wake-on-wlan-password=.*$" $WIFI_WOWL_CONF_PATH
+
+    snap set network-manager wifi.wake-on-wlan=
+    wait_for_network_manager
+    grep -v "^wifi.wake-on-wlan=.*$" $WIFI_WOWL_CONF_PATH
+    grep -v "^wifi.wake-on-wlan-password=.*$" $WIFI_WOWL_CONF_PATH
diff --git a/tests/main/wifi-wowlan-enabled-correctly/task.yaml b/tests/main/wifi-wowlan-enabled-correctly/task.yaml
new file mode 100644
index 0000000..8fcaecc
--- /dev/null
+++ b/tests/main/wifi-wowlan-enabled-correctly/task.yaml
@@ -0,0 +1,30 @@
+summary: Verify WiFi WoWLAN can be enabled in NetworkManager globally via a snap config option
+
+execute: |
+    . $TESTSLIB/utilities.sh
+
+    # Enable WoWLAN globally for all new WiFi connections
+    snap set network-manager wifi.wake-on-wlan=any
+    wait_for_network_manager
+
+    # Get us an AP via the wifi-ap we can use to create a connection to
+    create_ap Ubuntu
+
+    # Connect to the AP and ensure the connection was established
+    /snap/bin/network-manager.nmcli d wifi | grep Ubuntu
+    /snap/bin/network-manager.nmcli d wifi connect Ubuntu
+    /snap/bin/network-manager.nmcli d | grep 'wlan1.*connected'
+
+    # Now that we're connected a new connection exists which we can look at
+    # to verify that the WoWLAN key is correctly set.
+    /snap/bin/network-manager.nmcli c show Ubuntu | grep '802-11-wireless.wake-on-wlan:.*0x1 (default)'
+
+    if [ "$SPREAD_SYSTEM" = "hw-ubuntu-core-16" ]; then
+        if ! iw phy phy0 info | grep -q "WoWLAN support:" ; then
+            echo "INFO: Hardware does not support WoWLAN so we're not testing application"
+            echo "      of the configuration option on the hardware."
+            exit 0
+        fi
+        iw phy phy0 wowlan show | grep "WoWLAN is enabled"
+        iw phy phy0 wowlan show | grep "wake up on special any trigger"
+    fi
-- 
ubuntu-desktop mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-desktop

Reply via email to