mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 04:52:10 -07:00
Further tests for mapping dot11 frequencies to channels as ch177 was not discovered correctly based on freq
This commit is contained in:
parent
badd13181d
commit
daf2f943e2
1 changed files with 23 additions and 10 deletions
|
@ -6,26 +6,39 @@ import (
|
||||||
"github.com/evilsocket/islazy/data"
|
"github.com/evilsocket/islazy/data"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Define test data for dot11 frequency <-> channel tests
|
||||||
|
type dot11pair struct {
|
||||||
|
frequency int
|
||||||
|
channel int
|
||||||
|
}
|
||||||
|
|
||||||
|
var dot11TestVector = []dot11pair{
|
||||||
|
{2472, 13},
|
||||||
|
{2484, 14},
|
||||||
|
{5825, 165},
|
||||||
|
{5885, 177},
|
||||||
|
}
|
||||||
|
|
||||||
func buildExampleWiFi() *WiFi {
|
func buildExampleWiFi() *WiFi {
|
||||||
aliases := &data.UnsortedKV{}
|
aliases := &data.UnsortedKV{}
|
||||||
return NewWiFi(buildExampleEndpoint(), aliases, func(ap *AccessPoint) {}, func(ap *AccessPoint) {})
|
return NewWiFi(buildExampleEndpoint(), aliases, func(ap *AccessPoint) {}, func(ap *AccessPoint) {})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDot11Freq2Chan(t *testing.T) {
|
func TestDot11Freq2Chan(t *testing.T) {
|
||||||
exampleFreq := 2472
|
for _, entry := range dot11TestVector {
|
||||||
exp := 13
|
gotChannel := Dot11Freq2Chan(entry.frequency)
|
||||||
got := Dot11Freq2Chan(exampleFreq)
|
if gotChannel != entry.channel {
|
||||||
if got != exp {
|
t.Fatalf("expected '%v', got '%v'", entry.channel, gotChannel)
|
||||||
t.Fatalf("expected '%v', got '%v'", exp, got)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDot11Chan2Freq(t *testing.T) {
|
func TestDot11Chan2Freq(t *testing.T) {
|
||||||
exampleChan := 13
|
for _, entry := range dot11TestVector {
|
||||||
exp := 2472
|
gotFrequency := Dot11Chan2Freq(entry.channel)
|
||||||
got := Dot11Chan2Freq(exampleChan)
|
if gotFrequency != entry.frequency {
|
||||||
if got != exp {
|
t.Fatalf("expected '%v', got '%v'", entry.frequency, gotFrequency)
|
||||||
t.Fatalf("expected '%v', got '%v'", exp, got)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue