Skip to content

Commit

Permalink
Re-vendor distribution, which has better error messages for login aut…
Browse files Browse the repository at this point in the history
…h errors

Signed-off-by: Ying Li <ying.li@docker.com>
  • Loading branch information
cyli committed Sep 22, 2016
1 parent 97e09ae commit 272b194
Show file tree
Hide file tree
Showing 43 changed files with 1,333 additions and 443 deletions.
103 changes: 69 additions & 34 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion cmd/notary/tuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"strings"
"time"

"golang.org/x/crypto/ssh/terminal"

"github.com/Sirupsen/logrus"
"github.com/docker/distribution/registry/client/auth"
"github.com/docker/distribution/registry/client/transport"
Expand Down Expand Up @@ -746,7 +748,8 @@ type passwordStore struct {
}

func (ps passwordStore) Basic(u *url.URL) (string, string) {
if ps.anonymous {
// if it's not a terminal, don't wait on input
if ps.anonymous || !terminal.IsTerminal(int(os.Stdin.Fd())) {
return "", ""
}

Expand Down Expand Up @@ -786,6 +789,15 @@ func (ps passwordStore) Basic(u *url.URL) (string, string) {
return username, password
}

// to comply with the CredentialStore interface
func (ps passwordStore) RefreshToken(u *url.URL, service string) string {
return ""
}

// to comply with the CredentialStore interface
func (ps passwordStore) SetRefreshToken(u *url.URL, service string, token string) {
}

type httpAccess int

const (
Expand Down
17 changes: 17 additions & 0 deletions cmd/notary/tuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package main
import (
"net/http"
"net/http/httptest"
"net/url"
"os"
"path/filepath"
"testing"

"github.com/docker/distribution/registry/client/auth"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -219,3 +221,18 @@ func TestGetTrustPinningErrors(t *testing.T) {
tc.sha256 = "88b76b34ab83a9e4d5abe3697950fb73f940aab1aa5b534f80cf9de9708942be"
require.Error(t, tc.tufAddByHash(&cobra.Command{}, []string{"gun", "test1", "100"}))
}

func TestPasswordStore(t *testing.T) {
myurl, err := url.Parse("https://docker.io")
require.NoError(t, err)

// whether or not we're anonymous, because this isn't a terminal,
for _, ps := range []auth.CredentialStore{passwordStore{}, passwordStore{anonymous: true}} {
username, passwd := ps.Basic(myurl)
require.Equal(t, "", username)
require.Equal(t, "", passwd)

ps.SetRefreshToken(myurl, "someService", "token") // doesn't return an error, just want to make sure no state changes
require.Equal(t, "", ps.RefreshToken(myurl, "someService"))
}
}
38 changes: 0 additions & 38 deletions vendor/github.com/docker/distribution/.drone.yml

This file was deleted.

6 changes: 5 additions & 1 deletion vendor/github.com/docker/distribution/.mailmap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 272b194

Please sign in to comment.