github.com/la5nta/wl2k-go@v0.11.8/fbb/secure_test.go (about)

     1  // Copyright 2015 Martin Hebnes Pedersen (LA5NTA). All rights reserved.
     2  // Use of this source code is governed by the MIT-license that can be
     3  // found in the LICENSE file.
     4  
     5  package fbb
     6  
     7  import "testing"
     8  
     9  func TestSecureLoginResponse(t *testing.T) {
    10  	type test struct{ challenge, password, expect string }
    11  
    12  	tests := []test{
    13  		{challenge: "23753528", password: "FOOBAR", expect: "72768415"},
    14  		{challenge: "23753528", password: "FooBar", expect: "95074758"},
    15  	}
    16  
    17  	for i, v := range tests {
    18  		if got := secureLoginResponse(v.challenge, v.password); got != v.expect {
    19  			t.Errorf("%d: Got unexpected login response, expected '%s' got '%s'.", i, v.expect, got)
    20  		}
    21  	}
    22  }
    23  
    24  func BenchmarkSecureLoginResponse(b *testing.B) {
    25  	for i := 0; i < b.N; i++ {
    26  		secureLoginResponse("23753528", "foobar")
    27  	}
    28  }