Merge ~morphis/snappy-hwe-snaps/+git/wpa-supplicant:f/add-connect-tests into ~snappy-hwe-team/snappy-hwe-snaps/+git/wpa-supplicant:master

Proposed by Simon Fels
Status: Merged
Approved by: Matteo Croce
Approved revision: 37f220ae00c83c941f8c1349069cfac1337d87a4
Merged at revision: a3bc36bace3d7df57407fb8f75bdc64734384a54
Proposed branch: ~morphis/snappy-hwe-snaps/+git/wpa-supplicant:f/add-connect-tests
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/wpa-supplicant:master
Diff against target: 129 lines (+109/-0)
3 files modified
tests/lib/utilities.sh (+4/-0)
tests/main/sta-connect-open/task.yaml (+51/-0)
tests/main/sta-connect-wpa2/task.yaml (+54/-0)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Matteo Croce (community) Approve
Review via email: mp+320478@code.launchpad.net

Description of the change

Add test cases to verify open/secured connections

To post a comment you must log in.
Revision history for this message
Matteo Croce (teknoraver) :
review: Approve
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
2index dcca1a5..eb4e2ea 100644
3--- a/tests/lib/utilities.sh
4+++ b/tests/lib/utilities.sh
5@@ -29,3 +29,7 @@ install_snap_under_test() {
6 done
7 fi
8 }
9+
10+is_snap_installed() {
11+ snap list | grep -q $1
12+}
13diff --git a/tests/main/sta-connect-open/task.yaml b/tests/main/sta-connect-open/task.yaml
14new file mode 100644
15index 0000000..27e2778
16--- /dev/null
17+++ b/tests/main/sta-connect-open/task.yaml
18@@ -0,0 +1,51 @@
19+summary: Verify that a connection to an open WiFi network is possible
20+
21+environment:
22+ WIFI_SSID: Ubuntu
23+
24+restore: |
25+ if [ "$SPREAD_SYSTEM" = "ubuntu-core-16" ]; then
26+ rmmod mac80211_hwsim
27+ fi
28+
29+execute: |
30+ . $TESTSLIB/utilities.sh
31+
32+ if [ "$SPREAD_SYSTEM" = "ubuntu-core-16" ]; then
33+ # Get two connected wifi network interfaces wlan0 and wlan1 and
34+ # give the system soem time to settle
35+ modprobe mac80211_hwsim radios=2
36+ sleep 1
37+ fi
38+
39+ if ! is_snap_installed network-manager ; then
40+ snap install --edge network-manager
41+ snap connect network-manager:wpa wpa-supplicant:service
42+ wait_for_systemd_service snap.network-manager.networkmanager
43+ fi
44+
45+ if ! is_snap_installed wifi-ap ; then
46+ snap install wifi-ap
47+ # FIXME: until the wifi-ap utility is clever enough to retry
48+ # connecting with the service we need to add a short sleep here
49+ sleep 0.5
50+ fi
51+
52+ # Setup the access point with no security
53+ /snap/bin/wifi-ap.config set \
54+ wifi.interface=$HW_WLAN0_NAME \
55+ wifi.ssid=$WIFI_SSID \
56+ disabled=false
57+
58+ # AP needs a bit to appear and be visible for NetworkManager
59+ /snap/bin/nmcli d wifi rescan
60+ while ! /snap/bin/nmcli d wifi | grep Ubuntu ; do
61+ /snap/bin/nmcli d wifi rescan
62+ sleep 1
63+ done
64+
65+ /snap/bin/nmcli d wifi | grep $WIFI_SSID
66+
67+ # Connect to the AP and ensure the connection was established
68+ /snap/bin/nmcli d wifi connect $WIFI_SSID
69+ /snap/bin/nmcli d | grep "$HW_WLAN1_NAME.*connected"
70diff --git a/tests/main/sta-connect-wpa2/task.yaml b/tests/main/sta-connect-wpa2/task.yaml
71new file mode 100644
72index 0000000..4a557ac
73--- /dev/null
74+++ b/tests/main/sta-connect-wpa2/task.yaml
75@@ -0,0 +1,54 @@
76+summary: Verify that a connection to an WPA2-PSK secured WiFi network is possible
77+
78+environment:
79+ WIFI_SSID: Ubuntu
80+ WIFI_PASSPHRASE: Test1234
81+
82+restore: |
83+ if [ "$SPREAD_SYSTEM" = "ubuntu-core-16" ]; then
84+ rmmod mac80211_hwsim
85+ fi
86+
87+execute: |
88+ . $TESTSLIB/utilities.sh
89+
90+ if [ "$SPREAD_SYSTEM" = "ubuntu-core-16" ]; then
91+ # Get two connected wifi network interfaces wlan0 and wlan1 and
92+ # give the system soem time to settle
93+ modprobe mac80211_hwsim radios=2
94+ sleep 1
95+ fi
96+
97+ if ! is_snap_installed network-manager ; then
98+ snap install --edge network-manager
99+ snap connect network-manager:wpa wpa-supplicant:service
100+ wait_for_systemd_service snap.network-manager.networkmanager
101+ fi
102+
103+ if ! is_snap_installed wifi-ap ; then
104+ snap install wifi-ap
105+ # FIXME: until the wifi-ap utility is clever enough to retry
106+ # connecting with the service we need to add a short sleep here
107+ sleep 0.5
108+ fi
109+
110+ # Setup the access point with no security
111+ /snap/bin/wifi-ap.config set \
112+ wifi.interface=$HW_WLAN0_NAME \
113+ wifi.ssid=$WIFI_SSID \
114+ wifi.security=wpa2 \
115+ wifi.security-passphrase=$WIFI_PASSPHRASE \
116+ disabled=false
117+
118+ # AP needs a bit to appear and be visible for NetworkManager
119+ /snap/bin/nmcli d wifi rescan
120+ while ! /snap/bin/nmcli d wifi | grep Ubuntu ; do
121+ /snap/bin/nmcli d wifi rescan
122+ sleep 1
123+ done
124+
125+ /snap/bin/nmcli d wifi | grep $WIFI_SSID
126+
127+ # Connect to the AP and ensure the connection was established
128+ /snap/bin/nmcli d wifi connect $WIFI_SSID password $WIFI_PASSPHRASE
129+ /snap/bin/nmcli d | grep "$HW_WLAN1_NAME.*connected"

Subscribers

People subscribed via source and target branches

to all changes: