mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
coverage: add failure injection framework
Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
committed by
Ramkumar Chinchani
parent
f47c8222c2
commit
e0a1a82890
@@ -43,6 +43,7 @@ import (
|
||||
"zotregistry.io/zot/pkg/api"
|
||||
"zotregistry.io/zot/pkg/api/config"
|
||||
"zotregistry.io/zot/pkg/storage"
|
||||
"zotregistry.io/zot/pkg/test"
|
||||
. "zotregistry.io/zot/test"
|
||||
)
|
||||
|
||||
@@ -2083,6 +2084,29 @@ func TestAuthorizationWithBasicAuth(t *testing.T) {
|
||||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
|
||||
|
||||
resp, err = resty.R().SetBasicAuth(username, passphrase).
|
||||
Get(baseURL + "/v2/" + AuthorizationNamespace + "/tags/list")
|
||||
So(err, ShouldBeNil)
|
||||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
|
||||
|
||||
Convey("Hard to reach cases", func() {
|
||||
injected := test.InjectFailure(0)
|
||||
|
||||
// get tags with read access should get 200
|
||||
conf.AccessControl.Repositories[AuthorizationNamespace].Policies[0].Actions =
|
||||
append(conf.AccessControl.Repositories[AuthorizationNamespace].Policies[0].Actions, "read")
|
||||
resp, err = resty.R().SetBasicAuth(username, passphrase).
|
||||
Get(baseURL + "/v2/" + AuthorizationNamespace + "/tags/list")
|
||||
So(err, ShouldBeNil)
|
||||
So(resp, ShouldNotBeNil)
|
||||
if injected {
|
||||
So(resp.StatusCode(), ShouldEqual, http.StatusNotFound)
|
||||
} else {
|
||||
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
|
||||
}
|
||||
})
|
||||
|
||||
// head blob should get 200 now
|
||||
resp, err = resty.R().SetBasicAuth(username, passphrase).
|
||||
Head(baseURL + "/v2/" + AuthorizationNamespace + "/blobs/" + digest)
|
||||
@@ -2838,6 +2862,24 @@ func TestParallelRequests(t *testing.T) {
|
||||
assert.Equal(t, err, nil, "Error should be nil")
|
||||
assert.Equal(t, headResponse.StatusCode(), http.StatusNotFound, "response status code should return 404")
|
||||
|
||||
Convey("Hard to reach cases", t, func() {
|
||||
_ = test.InjectFailure(0)
|
||||
|
||||
headResponse, err := client.R().SetBasicAuth(username, passphrase).
|
||||
Head(baseURL + "/v2/" + testcase.destImageName + "/manifests/test:1.0")
|
||||
assert.Equal(t, err, nil, "Error should be nil")
|
||||
assert.Equal(t, headResponse.StatusCode(), http.StatusNotFound, "response status code should return 404")
|
||||
})
|
||||
|
||||
Convey("Hard to reach cases", t, func() {
|
||||
_ = test.InjectFailure(1)
|
||||
|
||||
headResponse, err := client.R().SetBasicAuth(username, passphrase).
|
||||
Head(baseURL + "/v2/" + testcase.destImageName + "/manifests/test:1.0")
|
||||
assert.Equal(t, err, nil, "Error should be nil")
|
||||
assert.Equal(t, headResponse.StatusCode(), http.StatusNotFound, "response status code should return 404")
|
||||
})
|
||||
|
||||
getResponse, err := client.R().SetBasicAuth(username, passphrase).
|
||||
Get(baseURL + "/v2/" + testcase.destImageName + "/manifests/" + manifest)
|
||||
assert.Equal(t, err, nil, "Error should be nil")
|
||||
|
||||
Reference in New Issue
Block a user