forked from TrueCloudLab/distribution
Use basic auth for private registries when over HTTPS.
RequestFactory is no longer a singleton (can be different for different instances of Registry) Registry now has an indexEndpoint member Registry methods that needed the indexEndpoint parameter no longer do so Registry methods will only use token auth where applicable if basic auth is not enabled.
This commit is contained in:
parent
a7b957f06f
commit
097f41245a
2 changed files with 51 additions and 20 deletions
|
@ -15,7 +15,7 @@ var (
|
|||
|
||||
func spawnTestRegistry(t *testing.T) *Registry {
|
||||
authConfig := &auth.AuthConfig{}
|
||||
r, err := NewRegistry("", authConfig, utils.NewHTTPRequestFactory())
|
||||
r, err := NewRegistry(authConfig, utils.NewHTTPRequestFactory(), makeURL("/v1/"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ func TestGetRemoteTags(t *testing.T) {
|
|||
|
||||
func TestGetRepositoryData(t *testing.T) {
|
||||
r := spawnTestRegistry(t)
|
||||
data, err := r.GetRepositoryData(makeURL("/v1/"), "foo42/bar")
|
||||
data, err := r.GetRepositoryData("foo42/bar")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -168,15 +168,14 @@ func TestPushImageJSONIndex(t *testing.T) {
|
|||
Checksum: "sha256:bea7bf2e4bacd479344b737328db47b18880d09096e6674165533aa994f5e9f2",
|
||||
},
|
||||
}
|
||||
ep := makeURL("/v1/")
|
||||
repoData, err := r.PushImageJSONIndex(ep, "foo42/bar", imgData, false, nil)
|
||||
repoData, err := r.PushImageJSONIndex("foo42/bar", imgData, false, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if repoData == nil {
|
||||
t.Fatal("Expected RepositoryData object")
|
||||
}
|
||||
repoData, err = r.PushImageJSONIndex(ep, "foo42/bar", imgData, true, []string{ep})
|
||||
repoData, err = r.PushImageJSONIndex("foo42/bar", imgData, true, []string{r.indexEndpoint})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue