file_test.go 711 B

123456789101112131415161718192021222324252627
  1. package configfile
  2. import (
  3. "testing"
  4. "github.com/docker/docker/api/types"
  5. )
  6. func TestEncodeAuth(t *testing.T) {
  7. newAuthConfig := &types.AuthConfig{Username: "ken", Password: "test"}
  8. authStr := encodeAuth(newAuthConfig)
  9. decAuthConfig := &types.AuthConfig{}
  10. var err error
  11. decAuthConfig.Username, decAuthConfig.Password, err = decodeAuth(authStr)
  12. if err != nil {
  13. t.Fatal(err)
  14. }
  15. if newAuthConfig.Username != decAuthConfig.Username {
  16. t.Fatal("Encode Username doesn't match decoded Username")
  17. }
  18. if newAuthConfig.Password != decAuthConfig.Password {
  19. t.Fatal("Encode Password doesn't match decoded Password")
  20. }
  21. if authStr != "a2VuOnRlc3Q=" {
  22. t.Fatal("AuthString encoding isn't correct.")
  23. }
  24. }