mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-05 10:10:12 +01:00
remove useless code
This commit is contained in:
parent
1144a1a289
commit
be4601b2fc
@ -25,7 +25,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/vmware/harbor/utils/log"
|
//"github.com/vmware/harbor/utils/log"
|
||||||
"github.com/vmware/harbor/utils/registry/auth"
|
"github.com/vmware/harbor/utils/registry/auth"
|
||||||
"github.com/vmware/harbor/utils/registry/errors"
|
"github.com/vmware/harbor/utils/registry/errors"
|
||||||
)
|
)
|
||||||
@ -48,7 +48,7 @@ type tagResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
log.SetLevel(log.DebugLevel)
|
//log.SetLevel(log.DebugLevel)
|
||||||
credential = auth.NewBasicAuthCredential(username, password)
|
credential = auth.NewBasicAuthCredential(username, password)
|
||||||
|
|
||||||
tokenServer = initTokenServer()
|
tokenServer = initTokenServer()
|
||||||
@ -157,8 +157,8 @@ func TestListTag(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListTagWithInvalidUser(t *testing.T) {
|
func TestListTagWithInvalidCredential(t *testing.T) {
|
||||||
credential := auth.NewBasicAuthCredential("user", "test")
|
credential := auth.NewBasicAuthCredential(username, "wrong_password")
|
||||||
client, err := NewRepositoryWithCredential(repo, registryServer.URL, credential)
|
client, err := NewRepositoryWithCredential(repo, registryServer.URL, credential)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@ -174,38 +174,3 @@ func TestListTagWithInvalidUser(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*tokenHandler := func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
username, _, ok := r.BasicAuth()
|
|
||||||
if !ok {
|
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
service := r.FormValue("service")
|
|
||||||
scopes := r.URL.Query()["scope"]
|
|
||||||
access := token_util.GetResourceActions(scopes)
|
|
||||||
|
|
||||||
token, _, issuedAt, err := token_util.MakeToken(username, service, access)
|
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result := make(map[string]interface{})
|
|
||||||
result["token"] = token
|
|
||||||
result["expires_in"] = "dfsd"
|
|
||||||
result["issued_at"] = issuedAt.Format(time.RFC3339)
|
|
||||||
|
|
||||||
encoder := json.NewEncoder(w)
|
|
||||||
if err = encoder.Encode(result); err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tokenServer := httptest.NewServer(http.HandlerFunc(tokenHandler))
|
|
||||||
defer tokenServer.Close()
|
|
||||||
*/
|
|
||||||
|
Loading…
Reference in New Issue
Block a user