Merge ~teknoraver/snappy-hwe-snaps/+git/wifi-ap:wpapass into ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master
- Git
- lp:~teknoraver/snappy-hwe-snaps/+git/wifi-ap
- wpapass
- Merge into master
Status: | Merged |
---|---|
Approved by: | Simon Fels |
Approved revision: | df8df420f7d8357995f0fa1a53fbac01e26223bf |
Merged at revision: | 67a49951c04daac96a28269bc257ea171b66d5e0 |
Proposed branch: | ~teknoraver/snappy-hwe-snaps/+git/wifi-ap:wpapass |
Merge into: | ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master |
Diff against target: |
364 lines (+154/-41) 12 files modified
.spread-reuse.22327.yaml (+9/-0) cmd/client/cmd_wizard.go (+36/-7) cmd/client/cmd_wizard_test.go (+62/-0) dev/null (+0/-23) docs/basic-ap-setup.md (+8/-0) docs/installation.md (+2/-2) tests/lib/restore-each.sh (+4/-0) tests/lib/utilities.sh (+22/-0) tests/main/conf-wizard-auto-at-boot/task.yaml (+3/-1) tests/main/default-conf-brings-up-ap/task.yaml (+3/-4) tests/main/stress-ap-status-control/task.yaml (+4/-2) tests/main/utf8-ssid/task.yaml (+1/-2) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
System Enablement Bot | continuous-integration | Approve | |
Simon Fels | Approve | ||
Konrad Zapałowicz (community) | code | Approve | |
Review via email: mp+320490@code.launchpad.net |
Commit message
Description of the change
Generate automatically a WPA password
Konrad Zapałowicz (kzapalowicz) wrote : | # |
Simon Fels (morphis) : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:4cbb3342575
https:/
Executed test runs:
FAILURE: https:/
None: https:/
FAILURE: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Simon Fels (morphis) : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:c45afa2a5f0
https:/
Executed test runs:
FAILURE: https:/
None: https:/
FAILURE: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:27b09605c6c
https:/
Executed test runs:
FAILURE: https:/
None: https:/
FAILURE: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:dcc0cd5ee4f
https:/
Executed test runs:
FAILURE: https:/
None: https:/
FAILURE: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3681c8fefd3
https:/
Executed test runs:
FAILURE: https:/
None: https:/
FAILURE: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:38d5955936c
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Konrad Zapałowicz (kzapalowicz) wrote : | # |
comments inline
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:68688ee20c4
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:ad3ce5a317c
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Konrad Zapałowicz (kzapalowicz) wrote : | # |
ack
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:61aad44b337
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:779efba04ff
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Simon Fels (morphis) : | # |
Simon Fels (morphis) : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:e863357b550
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:18f3faa520d
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Simon Fels (morphis) : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3d4ff1d5564
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:1abdf717757
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | diff --git a/.spread-reuse.22327.yaml b/.spread-reuse.22327.yaml | |||
2 | 0 | new file mode 100644 | 0 | new file mode 100644 |
3 | index 0000000..f54942f | |||
4 | --- /dev/null | |||
5 | +++ b/.spread-reuse.22327.yaml | |||
6 | @@ -0,0 +1,9 @@ | |||
7 | 1 | backends: | ||
8 | 2 | qemu: | ||
9 | 3 | systems: | ||
10 | 4 | - ubuntu-core-16: | ||
11 | 5 | username: test | ||
12 | 6 | password: test | ||
13 | 7 | address: localhost:59377 | ||
14 | 8 | data: | ||
15 | 9 | pid: 22341 | ||
16 | diff --git a/cmd/client/cmd_wizard.go b/cmd/client/cmd_wizard.go | |||
17 | index a8b9bb2..41dd538 100644 | |||
18 | --- a/cmd/client/cmd_wizard.go | |||
19 | +++ b/cmd/client/cmd_wizard.go | |||
20 | @@ -18,9 +18,11 @@ package main | |||
21 | 18 | import ( | 18 | import ( |
22 | 19 | "bufio" | 19 | "bufio" |
23 | 20 | "bytes" | 20 | "bytes" |
24 | 21 | "encoding/base64" | ||
25 | 21 | "encoding/json" | 22 | "encoding/json" |
26 | 22 | "fmt" | 23 | "fmt" |
27 | 23 | "log" | 24 | "log" |
28 | 25 | "math/rand" | ||
29 | 24 | "net" | 26 | "net" |
30 | 25 | "net/http" | 27 | "net/http" |
31 | 26 | "os" | 28 | "os" |
32 | @@ -28,8 +30,11 @@ import ( | |||
33 | 28 | "regexp" | 30 | "regexp" |
34 | 29 | "strconv" | 31 | "strconv" |
35 | 30 | "strings" | 32 | "strings" |
36 | 33 | "time" | ||
37 | 31 | ) | 34 | ) |
38 | 32 | 35 | ||
39 | 36 | const DefaultPassworthLength = 16 | ||
40 | 37 | |||
41 | 33 | type wizardStep func(map[string]interface{}, *bufio.Reader, bool) error | 38 | type wizardStep func(map[string]interface{}, *bufio.Reader, bool) error |
42 | 34 | 39 | ||
43 | 35 | // Go stores both IPv4 and IPv6 as [16]byte | 40 | // Go stores both IPv4 and IPv6 as [16]byte |
44 | @@ -40,7 +45,7 @@ const ipv4Offset = net.IPv6len - net.IPv4len | |||
45 | 40 | var defaultIp = net.IPv4(10, 0, 60, 1) | 45 | var defaultIp = net.IPv4(10, 0, 60, 1) |
46 | 41 | 46 | ||
47 | 42 | // Utility function to read input and strip the trailing \n | 47 | // Utility function to read input and strip the trailing \n |
49 | 43 | func readUserInput(reader *bufio.Reader) string { | 48 | var readUserInput = func (reader *bufio.Reader) string { |
50 | 44 | ret, err := reader.ReadString('\n') | 49 | ret, err := reader.ReadString('\n') |
51 | 45 | if err != nil { | 50 | if err != nil { |
52 | 46 | panic(err) | 51 | panic(err) |
53 | @@ -98,6 +103,22 @@ func findFreeSubnet(startIp net.IP) (net.IP, error) { | |||
54 | 98 | return curIp, nil | 103 | return curIp, nil |
55 | 99 | } | 104 | } |
56 | 100 | 105 | ||
57 | 106 | func generatePassword(length int) string { | ||
58 | 107 | // base64 produces 4 byte for every 3 byte of input, rounded up | ||
59 | 108 | password := make([]byte, length / 4 * 3 + 3) | ||
60 | 109 | rand.Read(password) | ||
61 | 110 | return base64.StdEncoding.EncodeToString(password)[:length] | ||
62 | 111 | } | ||
63 | 112 | |||
64 | 113 | func askForPassword(reader *bufio.Reader) (string, error) { | ||
65 | 114 | fmt.Print("Please enter the WPA2 passphrase: ") | ||
66 | 115 | key := readUserInput(reader) | ||
67 | 116 | if len(key) < 8 || len(key) > 63 { | ||
68 | 117 | return "", fmt.Errorf("WPA2 passphrase must be between 8 and 63 characters") | ||
69 | 118 | } | ||
70 | 119 | return key, nil | ||
71 | 120 | } | ||
72 | 121 | |||
73 | 101 | var allSteps = [...]wizardStep{ | 122 | var allSteps = [...]wizardStep{ |
74 | 102 | // determine the WiFi interface | 123 | // determine the WiFi interface |
75 | 103 | func(configuration map[string]interface{}, reader *bufio.Reader, nonInteractive bool) error { | 124 | func(configuration map[string]interface{}, reader *bufio.Reader, nonInteractive bool) error { |
76 | @@ -150,7 +171,7 @@ var allSteps = [...]wizardStep{ | |||
77 | 150 | // Select WiFi encryption type | 171 | // Select WiFi encryption type |
78 | 151 | func(configuration map[string]interface{}, reader *bufio.Reader, nonInteractive bool) error { | 172 | func(configuration map[string]interface{}, reader *bufio.Reader, nonInteractive bool) error { |
79 | 152 | if nonInteractive { | 173 | if nonInteractive { |
81 | 153 | configuration["wifi.security"] = "open" | 174 | configuration["wifi.security"] = "wpa2" |
82 | 154 | return nil | 175 | return nil |
83 | 155 | } | 176 | } |
84 | 156 | 177 | ||
85 | @@ -172,12 +193,18 @@ var allSteps = [...]wizardStep{ | |||
86 | 172 | if configuration["wifi.security"] == "open" { | 193 | if configuration["wifi.security"] == "open" { |
87 | 173 | return nil | 194 | return nil |
88 | 174 | } | 195 | } |
93 | 175 | fmt.Print("Please enter the WPA2 passphrase: ") | 196 | if nonInteractive { |
94 | 176 | key := readUserInput(reader) | 197 | // Generate a random 16 characters alphanumeric password |
95 | 177 | if len(key) < 8 || len(key) > 63 { | 198 | configuration["wifi.security-passphrase"] = generatePassword(DefaultPassworthLength) |
96 | 178 | return fmt.Errorf("WPA2 passphrase must be between 8 and 63 characters") | 199 | return nil |
97 | 200 | } | ||
98 | 201 | |||
99 | 202 | // Ask the user for a valid password (min 8, max 63 chars) | ||
100 | 203 | if password, err := askForPassword(reader); err == nil { | ||
101 | 204 | configuration["wifi.security-passphrase"] = password | ||
102 | 205 | } else { | ||
103 | 206 | return err | ||
104 | 179 | } | 207 | } |
105 | 180 | configuration["wifi.security-passphrase"] = key | ||
106 | 181 | 208 | ||
107 | 182 | return nil | 209 | return nil |
108 | 183 | }, | 210 | }, |
109 | @@ -423,6 +450,8 @@ type wizardCommand struct { | |||
110 | 423 | } | 450 | } |
111 | 424 | 451 | ||
112 | 425 | func (cmd *wizardCommand) Execute(args []string) error { | 452 | func (cmd *wizardCommand) Execute(args []string) error { |
113 | 453 | rand.Seed(time.Now().UnixNano()) | ||
114 | 454 | |||
115 | 426 | // Setup some sane default values, we don't ask the user for everything | 455 | // Setup some sane default values, we don't ask the user for everything |
116 | 427 | configuration := make(map[string]interface{}) | 456 | configuration := make(map[string]interface{}) |
117 | 428 | 457 | ||
118 | diff --git a/cmd/client/cmd_wizard_test.go b/cmd/client/cmd_wizard_test.go | |||
119 | 429 | new file mode 100644 | 458 | new file mode 100644 |
120 | index 0000000..7bb7391 | |||
121 | --- /dev/null | |||
122 | +++ b/cmd/client/cmd_wizard_test.go | |||
123 | @@ -0,0 +1,62 @@ | |||
124 | 1 | // | ||
125 | 2 | // Copyright (C) 2017 Canonical Ltd | ||
126 | 3 | // | ||
127 | 4 | // This program is free software: you can redistribute it and/or modify | ||
128 | 5 | // it under the terms of the GNU General Public License version 3 as | ||
129 | 6 | // published by the Free Software Foundation. | ||
130 | 7 | // | ||
131 | 8 | // This program is distributed in the hope that it will be useful, | ||
132 | 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
133 | 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
134 | 11 | // GNU General Public License for more details. | ||
135 | 12 | // | ||
136 | 13 | // You should have received a copy of the GNU General Public License | ||
137 | 14 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
138 | 15 | |||
139 | 16 | package main | ||
140 | 17 | |||
141 | 18 | import ( | ||
142 | 19 | "bufio" | ||
143 | 20 | "math/rand" | ||
144 | 21 | "strconv" | ||
145 | 22 | "testing" | ||
146 | 23 | "time" | ||
147 | 24 | |||
148 | 25 | . "gopkg.in/check.v1" | ||
149 | 26 | ) | ||
150 | 27 | |||
151 | 28 | // gopkg.in/check.v1 stuff | ||
152 | 29 | func TestWizard(t *testing.T) { TestingT(t) } | ||
153 | 30 | |||
154 | 31 | type WizardSuite struct{} | ||
155 | 32 | |||
156 | 33 | var _ = Suite(&WizardSuite{}) | ||
157 | 34 | |||
158 | 35 | func (s *WizardSuite) SetUpTest(c *C) { | ||
159 | 36 | rand.Seed(time.Now().UnixNano()) | ||
160 | 37 | } | ||
161 | 38 | |||
162 | 39 | func mockUserInput(reply string) func (reader *bufio.Reader) string { | ||
163 | 40 | return func (_ *bufio.Reader) string { | ||
164 | 41 | return reply | ||
165 | 42 | } | ||
166 | 43 | } | ||
167 | 44 | |||
168 | 45 | var passRegExp = "[a-zA-Z0-9+/]{"+strconv.Itoa(DefaultPassworthLength)+"}" | ||
169 | 46 | |||
170 | 47 | func (s *WizardSuite) TestPasswordGeneration(c *C) { | ||
171 | 48 | password := generatePassword(DefaultPassworthLength) | ||
172 | 49 | c.Assert(password, HasLen, DefaultPassworthLength) | ||
173 | 50 | c.Assert(password, Matches, passRegExp) | ||
174 | 51 | |||
175 | 52 | readUserInput = mockUserInput("short") | ||
176 | 53 | password, err := askForPassword(nil) | ||
177 | 54 | c.Assert(err, NotNil) | ||
178 | 55 | |||
179 | 56 | readUserInput = mockUserInput("4/Valid+Passw0rd") | ||
180 | 57 | password, err = askForPassword(nil) | ||
181 | 58 | c.Assert(err, IsNil) | ||
182 | 59 | |||
183 | 60 | c.Assert(password, HasLen, DefaultPassworthLength) | ||
184 | 61 | c.Assert(password, Matches, passRegExp) | ||
185 | 62 | } | ||
186 | diff --git a/docs/basic-ap-setup.md b/docs/basic-ap-setup.md | |||
187 | index b535699..6fe0a09 100644 | |||
188 | --- a/docs/basic-ap-setup.md | |||
189 | +++ b/docs/basic-ap-setup.md | |||
190 | @@ -13,6 +13,14 @@ $ wifi-ap.status | |||
191 | 13 | 13 | ||
192 | 14 | if the automatic configuration was successful and the access point is already active. | 14 | if the automatic configuration was successful and the access point is already active. |
193 | 15 | 15 | ||
194 | 16 | By default the automatic wizard, which runs when the wifi-ap snap is installed, | ||
195 | 17 | will choose secure enough default password and will enable WPA2-PSK security. | ||
196 | 18 | You can find the selected password when logged into | ||
197 | 19 | the system the wifi-ap snap installed on by running the command: | ||
198 | 20 | ``` | ||
199 | 21 | $ sudo wifi-ap.config get wifi.security-passphrase | ||
200 | 22 | ``` | ||
201 | 23 | |||
202 | 16 | To enable the WiFi access point manually after the snap was installed and all plugs and slots are connected run the following command: | 24 | To enable the WiFi access point manually after the snap was installed and all plugs and slots are connected run the following command: |
203 | 17 | 25 | ||
204 | 18 | ``` | 26 | ``` |
205 | diff --git a/docs/installation.md b/docs/installation.md | |||
206 | index 720cb19..720e9ba 100644 | |||
207 | --- a/docs/installation.md | |||
208 | +++ b/docs/installation.md | |||
209 | @@ -41,8 +41,8 @@ $ snap connect wifi-ap:network-manager network-manager:service | |||
210 | 41 | |------|-------| | 41 | |------|-------| |
211 | 42 | | **WiFi SSID** | Ubuntu | | 42 | | **WiFi SSID** | Ubuntu | |
212 | 43 | | **WiFi Interface mode** | direct | | 43 | | **WiFi Interface mode** | direct | |
215 | 44 | | **WiFi Security** | open | | 44 | | **WiFi Security** | wpa2 | |
216 | 45 | | **WiFi Security Passphrase ** | | | 45 | | **WiFi Security Passphrase ** | Randomly chosen | |
217 | 46 | | **WiFi Channel** | 6 | | 46 | | **WiFi Channel** | 6 | |
218 | 47 | | **WiFi Network Interface** | wlan0 | | 47 | | **WiFi Network Interface** | wlan0 | |
219 | 48 | | **WiFi Address** | 192.168.7.1 | | 48 | | **WiFi Address** | 192.168.7.1 | |
220 | diff --git a/tests/lib/restore-each.sh b/tests/lib/restore-each.sh | |||
221 | index b0d1902..0cfc960 100644 | |||
222 | --- a/tests/lib/restore-each.sh | |||
223 | +++ b/tests/lib/restore-each.sh | |||
224 | @@ -31,6 +31,10 @@ netplan generate | |||
225 | 31 | netplan apply | 31 | netplan apply |
226 | 32 | 32 | ||
227 | 33 | # remove and reinsert the module to refresh all the wifi network settings | 33 | # remove and reinsert the module to refresh all the wifi network settings |
228 | 34 | pkill wpa_supplicant || true | ||
229 | 35 | while pidof wpa_supplicant; do | ||
230 | 36 | sleep .5 | ||
231 | 37 | done | ||
232 | 34 | rmmod mac80211_hwsim || true | 38 | rmmod mac80211_hwsim || true |
233 | 35 | modprobe mac80211_hwsim radios=2 | 39 | modprobe mac80211_hwsim radios=2 |
234 | 36 | wait_until_interface_is_available wlan0 | 40 | wait_until_interface_is_available wlan0 |
235 | diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh | |||
236 | index 83f2e9e..9190e21 100644 | |||
237 | --- a/tests/lib/utilities.sh | |||
238 | +++ b/tests/lib/utilities.sh | |||
239 | @@ -45,3 +45,25 @@ install_snap_under_test() { | |||
240 | 45 | snap connect wifi-ap:firewall-control core | 45 | snap connect wifi-ap:firewall-control core |
241 | 46 | fi | 46 | fi |
242 | 47 | } | 47 | } |
243 | 48 | |||
244 | 49 | # Connects to a WiFi network | ||
245 | 50 | # args1: interface to use | ||
246 | 51 | connect_to_wifi() { | ||
247 | 52 | local enc ssid pass | ||
248 | 53 | |||
249 | 54 | enc=$(/snap/bin/wifi-ap.config get wifi.security) | ||
250 | 55 | ssid=$(/snap/bin/wifi-ap.config get wifi.ssid) | ||
251 | 56 | if [ "$enc" = open ]; then | ||
252 | 57 | iw "$1" connect "$ssid" | ||
253 | 58 | else | ||
254 | 59 | pass=$(/snap/bin/wifi-ap.config get wifi.security-passphrase) | ||
255 | 60 | wpa_passphrase "$ssid" "$pass" >/tmp/wpa.conf | ||
256 | 61 | wpa_supplicant -B -c/tmp/wpa.conf -i"$1" | ||
257 | 62 | |||
258 | 63 | # Need to wait for a full scan and WPA2 handshake | ||
259 | 64 | for i in $(seq 60); do | ||
260 | 65 | iw dev "$1" link |fgrep -xq 'Not connected.' || break | ||
261 | 66 | sleep 1 | ||
262 | 67 | done | ||
263 | 68 | fi | ||
264 | 69 | } | ||
265 | diff --git a/tests/main/conf-wizard-auto-at-boot/task.yaml b/tests/main/conf-wizard-auto-at-boot/task.yaml | |||
266 | index b042097..13d5394 100644 | |||
267 | --- a/tests/main/conf-wizard-auto-at-boot/task.yaml | |||
268 | +++ b/tests/main/conf-wizard-auto-at-boot/task.yaml | |||
269 | @@ -5,7 +5,9 @@ execute: | | |||
270 | 5 | test "$(/snap/bin/wifi-ap.config get disabled)" = false | 5 | test "$(/snap/bin/wifi-ap.config get disabled)" = false |
271 | 6 | 6 | ||
272 | 7 | test "$(/snap/bin/wifi-ap.config get wifi.interface)" = wlan0 | 7 | test "$(/snap/bin/wifi-ap.config get wifi.interface)" = wlan0 |
274 | 8 | test "$(/snap/bin/wifi-ap.config get wifi.security)" = open | 8 | test "$(/snap/bin/wifi-ap.config get wifi.security)" = wpa2 |
275 | 9 | # Random 16 characters password, plus an ending line | ||
276 | 10 | test "$(/snap/bin/wifi-ap.config get wifi.security-passphrase |wc -c)" -eq 17 | ||
277 | 9 | test "$(/snap/bin/wifi-ap.config get wifi.ssid)" = Ubuntu | 11 | test "$(/snap/bin/wifi-ap.config get wifi.ssid)" = Ubuntu |
278 | 10 | test "$(/snap/bin/wifi-ap.config get wifi.address)" = 10.0.60.1 | 12 | test "$(/snap/bin/wifi-ap.config get wifi.address)" = 10.0.60.1 |
279 | 11 | 13 | ||
280 | diff --git a/tests/main/conf-wizard-auto/task.yaml b/tests/main/conf-wizard-auto/task.yaml | |||
281 | 12 | deleted file mode 100644 | 14 | deleted file mode 100644 |
282 | index ae6219c..0000000 | |||
283 | --- a/tests/main/conf-wizard-auto/task.yaml | |||
284 | +++ /dev/null | |||
285 | @@ -1,23 +0,0 @@ | |||
286 | 1 | summary: Verify that the automatic wizard works | ||
287 | 2 | |||
288 | 3 | execute: | | ||
289 | 4 | # The automatic wizard was already started | ||
290 | 5 | |||
291 | 6 | # Check that we get good default values | ||
292 | 7 | test "$(/snap/bin/wifi-ap.config get disabled)" = false | ||
293 | 8 | |||
294 | 9 | test "$(/snap/bin/wifi-ap.config get wifi.interface)" = wlan0 | ||
295 | 10 | test "$(/snap/bin/wifi-ap.config get wifi.security)" = open | ||
296 | 11 | test "$(/snap/bin/wifi-ap.config get wifi.ssid)" = Ubuntu | ||
297 | 12 | test "$(/snap/bin/wifi-ap.config get wifi.address)" = 10.0.60.1 | ||
298 | 13 | |||
299 | 14 | test "$(/snap/bin/wifi-ap.config get dhcp.range-start)" = 10.0.60.2 | ||
300 | 15 | test "$(/snap/bin/wifi-ap.config get dhcp.range-stop)" = 10.0.60.199 | ||
301 | 16 | |||
302 | 17 | default_route=$(ip route |awk '/default/{print$5}') | ||
303 | 18 | if [ -n "$default_route" ]; then | ||
304 | 19 | test "$(/snap/bin/wifi-ap.config get share.disabled)" = false | ||
305 | 20 | test "$(/snap/bin/wifi-ap.config get share.network-interface)" = "$default_route" | ||
306 | 21 | else | ||
307 | 22 | test "$(/snap/bin/wifi-ap.config get share.disabled)" = true | ||
308 | 23 | fi | ||
309 | diff --git a/tests/main/default-conf-brings-up-ap/task.yaml b/tests/main/default-conf-brings-up-ap/task.yaml | |||
310 | index 6777c8d..28b9363 100644 | |||
311 | --- a/tests/main/default-conf-brings-up-ap/task.yaml | |||
312 | +++ b/tests/main/default-conf-brings-up-ap/task.yaml | |||
313 | @@ -14,12 +14,11 @@ execute: | | |||
314 | 14 | # There should be only a single network | 14 | # There should be only a single network |
315 | 15 | network_count=`/snap/bin/wireless-tools.iw dev wlan1 scan | grep -c 'SSID: Ubuntu'` | 15 | network_count=`/snap/bin/wireless-tools.iw dev wlan1 scan | grep -c 'SSID: Ubuntu'` |
316 | 16 | test $network_count -eq 1 | 16 | test $network_count -eq 1 |
320 | 17 | # The AP should not be secured by default | 17 | # The AP should not be secured |
321 | 18 | ! /snap/bin/wireless-tools.iw dev wlan1 scan | grep 'WPA:' | 18 | /snap/bin/wireless-tools.iw dev wlan1 scan | grep 'RSN:' |
319 | 19 | ! /snap/bin/wireless-tools.iw dev wlan1 scan | grep 'RSN:' | ||
322 | 20 | 19 | ||
323 | 21 | # Verify we can associate with the AP | 20 | # Verify we can associate with the AP |
325 | 22 | /snap/bin/wireless-tools.iw wlan1 connect Ubuntu | 21 | connect_to_wifi wlan1 |
326 | 23 | /snap/bin/wireless-tools.iw dev wlan1 link | grep 'SSID: Ubuntu' | 22 | /snap/bin/wireless-tools.iw dev wlan1 link | grep 'SSID: Ubuntu' |
327 | 24 | 23 | ||
328 | 25 | # And we should get an IP address assigned over DHCP | 24 | # And we should get an IP address assigned over DHCP |
329 | diff --git a/tests/main/stress-ap-status-control/task.yaml b/tests/main/stress-ap-status-control/task.yaml | |||
330 | index 89ded92..7f3b4cf 100644 | |||
331 | --- a/tests/main/stress-ap-status-control/task.yaml | |||
332 | +++ b/tests/main/stress-ap-status-control/task.yaml | |||
333 | @@ -10,6 +10,8 @@ prepare: | | |||
334 | 10 | snap connect wireless-tools:network-control core | 10 | snap connect wireless-tools:network-control core |
335 | 11 | 11 | ||
336 | 12 | execute: | | 12 | execute: | |
337 | 13 | . $TESTSLIB/utilities.sh | ||
338 | 14 | |||
339 | 13 | # Bring up the access point first | 15 | # Bring up the access point first |
340 | 14 | /snap/bin/wifi-ap.config set disabled=false | 16 | /snap/bin/wifi-ap.config set disabled=false |
341 | 15 | until /snap/bin/wifi-ap.status | grep "ap.active: true" ; do | 17 | until /snap/bin/wifi-ap.status | grep "ap.active: true" ; do |
342 | @@ -60,8 +62,8 @@ execute: | | |||
343 | 60 | test $found_ap -eq 1 | 62 | test $found_ap -eq 1 |
344 | 61 | 63 | ||
345 | 62 | # Verify we can associate with the AP | 64 | # Verify we can associate with the AP |
348 | 63 | sudo /snap/bin/wireless-tools.iw wlan1 connect Ubuntu | 65 | connect_to_wifi wlan1 |
349 | 64 | sudo /snap/bin/wireless-tools.iw dev wlan1 link | grep 'SSID: Ubuntu' | 66 | /snap/bin/wireless-tools.iw dev wlan1 link | grep 'SSID: Ubuntu' |
350 | 65 | 67 | ||
351 | 66 | # We should only have one hostapd and one dnsmasq process at this time | 68 | # We should only have one hostapd and one dnsmasq process at this time |
352 | 67 | # (we have to ignore the grep'ing process as otherwise we get a count of 2) | 69 | # (we have to ignore the grep'ing process as otherwise we get a count of 2) |
353 | diff --git a/tests/main/utf8-ssid/task.yaml b/tests/main/utf8-ssid/task.yaml | |||
354 | index ad9e594..b4f53ae 100644 | |||
355 | --- a/tests/main/utf8-ssid/task.yaml | |||
356 | +++ b/tests/main/utf8-ssid/task.yaml | |||
357 | @@ -43,6 +43,5 @@ execute: | | |||
358 | 43 | test $network_count -eq 1 | 43 | test $network_count -eq 1 |
359 | 44 | 44 | ||
360 | 45 | # Verify we can associate with the AP | 45 | # Verify we can associate with the AP |
362 | 46 | /snap/bin/wireless-tools.iw wlan1 connect 'Ubuntu👍' | 46 | connect_to_wifi wlan1 |
363 | 47 | /snap/bin/wireless-tools.iw dev wlan1 link | fgrep 'SSID: Ubuntu\xf0\x9f\x91\x8d' | 47 | /snap/bin/wireless-tools.iw dev wlan1 link | fgrep 'SSID: Ubuntu\xf0\x9f\x91\x8d' |
364 | 48 |
change looks good however the code-layout could be improved for readability.