2016-04-21 18:37:08 -04:00
|
|
|
package configfile
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-09-06 14:18:12 -04:00
|
|
|
"github.com/docker/docker/api/types"
|
2016-04-21 18:37:08 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestEncodeAuth(t *testing.T) {
|
|
|
|
newAuthConfig := &types.AuthConfig{Username: "ken", Password: "test"}
|
|
|
|
authStr := encodeAuth(newAuthConfig)
|
|
|
|
decAuthConfig := &types.AuthConfig{}
|
|
|
|
var err error
|
|
|
|
decAuthConfig.Username, decAuthConfig.Password, 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.")
|
|
|
|
}
|
|
|
|
}
|