From 42bc430cfdba3bb1fbb133fd2a5ff2ed319bb50a Mon Sep 17 00:00:00 2001 From: Tan Jiang Date: Wed, 8 Mar 2017 13:57:34 +0800 Subject: [PATCH] update swagger, fix minor issues in test --- docs/swagger.yaml | 37 ++++++++++++++++++++++++-- src/common/utils/notary/helper_test.go | 6 ++++- src/common/utils/notary/test/server.go | 1 - 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 41ff42cf8..b024eb2fe 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,5 +1,3 @@ -# this is an example of the Uber API -# as a demonstration of an API spec in YAML swagger: '2.0' info: title: Harbor API @@ -786,6 +784,32 @@ paths: description: Retrieved manifests from a relevant repository not found. 500: description: Unexpected internal errors. + /repositories/signatures: + get: + summary: Get signature information of a repository + description: | + This endpoint aims to retrieve signature information of a repository, the data is + from the nested notary instance of Harbor. + If the repository does not have any signature information in notary, this API will + return an empty list with response code 200, instead of 404 + parameters: + - name: repo_name + in: query + type: string + required: true + description: repository name. + tags: + - Products + responses: + 200: + description: Retrieved signatures. + schema: + type: array + items: + $ref: '#/definitions/RepoSignature' + 500: + description: Server side error. + /repositories/top: get: summary: Get public repositories which are accessed most. @@ -2025,3 +2049,12 @@ definitions: email_identity: type: string description: The dentity of email server. + RepoSignature: + type: object + properties: + tag: + type: string + description: The tag of image. + hashes: + type: object + description: The JSON object of the hash of the image. diff --git a/src/common/utils/notary/helper_test.go b/src/common/utils/notary/helper_test.go index d3d98b856..61b802e23 100644 --- a/src/common/utils/notary/helper_test.go +++ b/src/common/utils/notary/helper_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/assert" notarytest "github.com/vmware/harbor/src/common/utils/notary/test" + "os" "path" "testing" ) @@ -16,7 +17,10 @@ func TestMain(m *testing.M) { defer notaryServer.Close() notaryEndpoint = notaryServer.URL notaryCachePath = "/tmp/notary" - m.Run() + result := m.Run() + if result != 0 { + os.Exit(result) + } } func TestGetTargets(t *testing.T) { diff --git a/src/common/utils/notary/test/server.go b/src/common/utils/notary/test/server.go index a6ba9e40f..9bf814abe 100644 --- a/src/common/utils/notary/test/server.go +++ b/src/common/utils/notary/test/server.go @@ -37,7 +37,6 @@ func NewNotaryServer(endpoint string) *httptest.Server { validRoot := fmt.Sprintf("/v2/%s/notary-demo/busybox/_trust/tuf/", endpoint) invalidRoot := fmt.Sprintf("/v2/%s/notary-demo/fail/_trust/tuf/", endpoint) p := currPath() - fmt.Printf("valid web root: %s, local path: %s\n", validRoot, path.Join(p, "valid")) mux.Handle(validRoot, http.StripPrefix(validRoot, http.FileServer(http.Dir(path.Join(p, "valid"))))) mux.Handle(invalidRoot, http.StripPrefix(invalidRoot, http.FileServer(http.Dir(path.Join(p, "invalid"))))) return httptest.NewServer(mux)