Created
January 22, 2011 16:49
-
-
Save jbrechtel/791235 to your computer and use it in GitHub Desktop.
Specs for NetworkParser.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.nevercertain.wifipasswords | |
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.Spec | |
class NetworkParserSpecs extends Spec with ShouldMatchers { | |
val singleNetwork = """ | |
network={ | |
ssid="Futurama" | |
psk="Bite my shiny metal ass" | |
key_mgmt=WPA-PSK | |
priority=16 | |
} | |
""" | |
val twoNetworks = """ | |
network={ | |
ssid="Futurama" | |
psk="Bite my shiny metal ass" | |
key_mgmt=WPA-PSK | |
priority=16 | |
} | |
network={ | |
ssid="Dune" | |
psk="Oogly boogly" | |
key_mgmt=WPA-PSK | |
priority=16 | |
} | |
""" | |
val wepNetwork = """ | |
network={ | |
ssid="joes wifi" | |
key_mgmt=NONE | |
auth_alg=OPEN SHARED | |
wep_key0=7108613811 | |
priority=25 | |
} | |
""" | |
val openNetwork = """ | |
network={ | |
ssid="gogoinflight" | |
key_mgmt=NONE | |
priority=2 | |
}""" | |
describe("parsing a network") { | |
it("should return a wifi network") { | |
val networks = NetworkParser.parse(singleNetwork) | |
networks.size should equal (1) | |
} | |
it("should find multiple wifi networks") { | |
val networks = NetworkParser.parse(twoNetworks) | |
networks.size should equal(2) | |
} | |
it("should create a network with the expected name") { | |
val networks = NetworkParser.parse(singleNetwork) | |
networks(0).name should equal("Futurama") | |
} | |
it("should create a WPA network with the expected password") { | |
val networks = NetworkParser.parse(singleNetwork) | |
networks(0).password should equal("Bite my shiny metal ass") | |
} | |
it("should create a WEP network with the expected password") { | |
val networks = NetworkParser.parse(wepNetwork) | |
networks(0).password should equal("7108613811") | |
} | |
it("should create a WPA network with the correct type") { | |
val networks = NetworkParser.parse(singleNetwork) | |
networks(0).networkType should equal(NetworkType.WPA) | |
} | |
it("should create a WEP network with the correct type") { | |
val networks = NetworkParser.parse(wepNetwork) | |
networks(0).networkType should equal(NetworkType.WEP) | |
} | |
it("should create an OPEN network with the correct type") { | |
val networks = NetworkParser.parse(openNetwork) | |
networks(0).networkType should equal(NetworkType.OPEN) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment