Skip to content

Commit

Permalink
fixing network test to recognize hashed passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
tvanriper committed Aug 7, 2022
1 parent 7d963ed commit 12dc6d5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions network_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wireless

import (
"fmt"
"testing"

. "github.com/smartystreets/goconvey/convey"
Expand All @@ -19,12 +20,13 @@ var openNet = Network{ID: 0, IDStr: "x", SSID: "gg"}
func TestSetCmds(t *testing.T) {
Convey("given a private network", t, func() {
n := pskNet
hashed := n.HashedPSK()

Convey("when the set commands are rendered", func() {
cmds := setCmds(n)

Convey("then it should have the basic fields", func() {
So(cmds, ShouldContain, `SET_NETWORK 0 psk "xx"`)
So(cmds, ShouldContain, fmt.Sprintf(`SET_NETWORK 0 psk %s`, hashed))
So(cmds, ShouldContain, `SET_NETWORK 0 ssid "gg"`)
})
})
Expand All @@ -33,13 +35,14 @@ func TestSetCmds(t *testing.T) {
Convey("given a disabled custom private network", t, func() {
n := pskNet2
n.Disable(true)
hashed := n.HashedPSK()

Convey("when the set commands are rendered", func() {
cmds := setCmds(n)
Println(cmds)

Convey("then it should have the basic fields", func() {
So(cmds, ShouldContain, `SET_NETWORK 0 psk "xx"`)
So(cmds, ShouldContain, fmt.Sprintf(`SET_NETWORK 0 psk %s`, hashed))
So(cmds, ShouldContain, `SET_NETWORK 0 ssid "gg"`)
So(cmds, ShouldContain, `SET_NETWORK 0 key_mgmt WPA2-TKIP`)
So(cmds, ShouldContain, `SET_NETWORK 0 disabled 1`)
Expand All @@ -66,13 +69,14 @@ func TestSetCmds(t *testing.T) {

Convey("when the password is reset", func() {
n.PSK = "horsewaffle"
hashed := n.HashedPSK()
Convey("when the set commands are rendered", func() {
cmds := setCmds(n)
Println(cmds)

Convey("then it should not contain the PSK", func() {
So(len(cmds), ShouldEqual, 4)
So(cmds, ShouldContain, `SET_NETWORK 0 psk "horsewaffle"`)
So(cmds, ShouldContain, fmt.Sprintf(`SET_NETWORK 0 psk %s`, hashed))
So(cmds, ShouldContain, `SET_NETWORK 0 ssid "gg"`)
So(cmds, ShouldContain, `SET_NETWORK 0 key_mgmt WPA2-TKIP`)
So(cmds, ShouldContain, `SET_NETWORK 0 scan_ssid 1`)
Expand Down

0 comments on commit 12dc6d5

Please sign in to comment.