mirror of
https://github.com/goharbor/harbor.git
synced 2024-06-27 23:35:10 +02:00
Update testcase for scan tag api change
Return 202 after success scan_summary is in a map struct
This commit is contained in:
parent
41b8e60e6a
commit
6af7d4bdf4
|
@ -135,7 +135,7 @@ func (ac *APIClient) Post(url string, data []byte) error {
|
|||
}
|
||||
|
||||
if resp.StatusCode != http.StatusCreated &&
|
||||
resp.StatusCode != http.StatusOK {
|
||||
resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted {
|
||||
if err := getErrorMessage(resp); err != nil {
|
||||
return fmt.Errorf("%s:%s", resp.Status, err.Error())
|
||||
}
|
||||
|
|
|
@ -17,6 +17,11 @@ type ImageUtil struct {
|
|||
testingClient *client.APIClient
|
||||
}
|
||||
|
||||
const (
|
||||
// MimeTypeNativeReport defines the mime type for native report
|
||||
MimeTypeNativeReport = "application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0"
|
||||
)
|
||||
|
||||
//NewImageUtil : Constructor
|
||||
func NewImageUtil(rootURI string, httpClient *client.APIClient) *ImageUtil {
|
||||
if len(strings.TrimSpace(rootURI)) == 0 || httpClient == nil {
|
||||
|
@ -76,8 +81,11 @@ func (iu *ImageUtil) ScanTag(repoName string, tagName string) error {
|
|||
return
|
||||
}
|
||||
|
||||
if tag.ScanOverview != nil && tag.ScanOverview.Status == "finished" {
|
||||
done <- true
|
||||
if tag.ScanOverview != nil {
|
||||
summary, ok := tag.ScanOverview[MimeTypeNativeReport]
|
||||
if ok && summary.Status == "Success" {
|
||||
done <- true
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
@ -86,7 +94,7 @@ func (iu *ImageUtil) ScanTag(repoName string, tagName string) error {
|
|||
case <-done:
|
||||
return nil
|
||||
case <-time.After(20 * time.Second):
|
||||
return errors.New("Scan timeout after 30 seconds")
|
||||
return errors.New("Scan timeout after 20 seconds")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ type Repository struct {
|
|||
|
||||
//Tag : For /api/repositories/:repo/tags
|
||||
type Tag struct {
|
||||
Digest string `json:"digest"`
|
||||
Name string `json:"name"`
|
||||
Signature map[string]interface{} `json:"signature, omitempty"`
|
||||
ScanOverview *ScanOverview `json:"scan_overview, omitempty"`
|
||||
Digest string `json:"digest"`
|
||||
Name string `json:"name"`
|
||||
Signature map[string]interface{} `json:"signature, omitempty"`
|
||||
ScanOverview map[string]ScanOverview `json:"scan_overview, omitempty"`
|
||||
}
|
||||
|
||||
//ScanOverview : For scanning
|
||||
|
|
Loading…
Reference in New Issue
Block a user