update swagger, fix minor issues in test

This commit is contained in:
Tan Jiang 2017-03-08 13:57:34 +08:00
parent 282c7f61c4
commit 42bc430cfd
3 changed files with 40 additions and 4 deletions

View File

@ -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.

View File

@ -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) {

View File

@ -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)