2013-03-14 20:43:59 -04:00
|
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEncodeAuth(t *testing.T) {
|
2013-03-22 05:19:39 -04:00
|
|
|
newAuthConfig := &AuthConfig{Username: "ken", Password: "test", Email: "test@example.com"}
|
2013-03-14 20:43:59 -04:00
|
|
|
authStr := EncodeAuth(newAuthConfig)
|
|
|
|
decAuthConfig, err := DecodeAuth(authStr)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if newAuthConfig.Username != decAuthConfig.Username {
|
|
|
|
t.Fatal("Encode Username doesn't match decoded Username")
|
|
|
|
}
|
|
|
|
if newAuthConfig.Password != decAuthConfig.Password {
|
|
|
|
t.Fatal("Encode Password doesn't match decoded Password")
|
|
|
|
}
|
|
|
|
if authStr != "a2VuOnRlc3Q=" {
|
|
|
|
t.Fatal("AuthString encoding isn't correct.")
|
|
|
|
}
|
|
|
|
}
|