Refresh notary test data

Refresh the valid signature data before it's expired

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
Daniel Jiang 2020-02-24 19:46:17 +08:00
parent 7a2090b6ca
commit 340726f7d3
9 changed files with 20 additions and 20 deletions

View File

@ -14,7 +14,7 @@ func TestMain(m *testing.M) {
// B/C the notary requires private key for signing token, b
// before running locally, please make sure the env var is set as follow:
// export TOKEN_PRIVATE_KEY_PATH="/harbor/tests/private_key.pem"
endpoint := "10.117.4.142"
endpoint := "jt-dev.local.goharbor.io"
// notary-demo/busybox:1.0 is signed, more details in the notary/test pkg
notaryServer := test.NewNotaryServer(endpoint)
defer notaryServer.Close()
@ -47,9 +47,9 @@ func TestGetCheckerByRepo(t *testing.T) {
}{
{
input: in{
repo: "notary-demo/busybox",
tag: "1.0",
digest: "sha256:1359608115b94599e5641638bac5aef1ddfaa79bb96057ebf41ebc8d33acf8a7",
repo: "library/busybox",
tag: "latest-signed",
digest: "sha256:dd97a3fe6d721c5cf03abac0f50e2848dc583f7c4e41bf39102ceb42edfd1808",
},
expect: res{
tagSigned: true,
@ -58,8 +58,8 @@ func TestGetCheckerByRepo(t *testing.T) {
},
{
input: in{
repo: "notary-demo/busybox",
tag: "1.0",
repo: "library/busybox",
tag: "latest-signed",
digest: "sha256:1359608115b94599e5641638bac5aef1ddfaa79bb96057ebf41ebc8d33acf8a8",
},
expect: res{
@ -69,9 +69,9 @@ func TestGetCheckerByRepo(t *testing.T) {
},
{
input: in{
repo: "notary-demo/busybox",
repo: "library/busybox",
tag: "2.0",
digest: "sha256:1359608115b94599e5641638bac5aef1ddfaa79bb96057ebf41ebc8d33acf8a7",
digest: "sha256:dd97a3fe6d721c5cf03abac0f50e2848dc583f7c4e41bf39102ceb42edfd1808",
},
expect: res{
tagSigned: false,

View File

@ -31,7 +31,7 @@ import (
"github.com/goharbor/harbor/src/common"
)
var endpoint = "10.117.4.142"
var endpoint = "jt-dev.local.goharbor.io"
var notaryServer *httptest.Server
func TestMain(m *testing.M) {
@ -54,19 +54,19 @@ func TestMain(m *testing.M) {
}
func TestGetInternalTargets(t *testing.T) {
targets, err := GetInternalTargets(notaryServer.URL, "admin", "notary-demo/busybox")
targets, err := GetInternalTargets(notaryServer.URL, "admin", "library/busybox")
assert.Nil(t, err, fmt.Sprintf("Unexpected error: %v", err))
assert.Equal(t, 1, len(targets), "")
assert.Equal(t, "1.0", targets[0].Tag, "")
assert.Equal(t, "latest-signed", targets[0].Tag, "")
}
func TestGetTargets(t *testing.T) {
targets, err := GetTargets(notaryServer.URL, "admin", path.Join(endpoint, "notary-demo/busybox"))
targets, err := GetTargets(notaryServer.URL, "admin", path.Join(endpoint, "library/busybox"))
assert.Nil(t, err, fmt.Sprintf("Unexpected error: %v", err))
assert.Equal(t, 1, len(targets), "")
assert.Equal(t, "1.0", targets[0].Tag, "")
assert.Equal(t, "latest-signed", targets[0].Tag, "")
targets, err = GetTargets(notaryServer.URL, "admin", path.Join(endpoint, "notary-demo/notexist"))
targets, err = GetTargets(notaryServer.URL, "admin", path.Join(endpoint, "library/notexist"))
assert.Nil(t, err, fmt.Sprintf("Unexpected error: %v", err))
assert.Equal(t, 0, len(targets), "Targets list should be empty for non exist repo.")
}

View File

@ -33,8 +33,8 @@ func currPath() string {
// NewNotaryServer creates a notary server for testing.
func NewNotaryServer(endpoint string) *httptest.Server {
mux := http.NewServeMux()
validRoot := fmt.Sprintf("/v2/%s/notary-demo/busybox/_trust/tuf/", endpoint)
invalidRoot := fmt.Sprintf("/v2/%s/notary-demo/fail/_trust/tuf/", endpoint)
validRoot := fmt.Sprintf("/v2/%s/library/busybox/_trust/tuf/", endpoint)
invalidRoot := fmt.Sprintf("/v2/%s/library/busybox/fail/_trust/tuf/", endpoint)
p := currPath()
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")))))

View File

@ -1 +1 @@
{"signed":{"_type":"Root","consistent_snapshot":false,"expires":"2027-03-13T19:40:40.104632513+08:00","keys":{"231efb776eb60d7a240a2b3deb3d458c32062cab05db69e62df838ac09214004":{"keytype":"ecdsa-x509","keyval":{"private":null,"public":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJpakNDQVRDZ0F3SUJBZ0lSQU5WNkpKblZLUHZtQ3NqVi9TcmFtVGt3Q2dZSUtvWkl6ajBFQXdJd0t6RXAKTUNjR0ExVUVBeE1nTVRBdU1URTNMalF1TVRReUwyNXZkR0Z5ZVMxa1pXMXZMMkoxYzNsaWIzZ3dIaGNOTVRjdwpNekUxTVRFME1ETTJXaGNOTWpjd016RXpNVEUwTURNMldqQXJNU2t3SndZRFZRUURFeUF4TUM0eE1UY3VOQzR4Ck5ESXZibTkwWVhKNUxXUmxiVzh2WW5WemVXSnZlREJaTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEEwSUEKQkNIU0JDc0VXSjV2emVaY2NTYjJkM2FNZzBzY0JhclVGV3dxR3dTZTVEN1hQSktxTW9SYlRNeFRRbmZlc25DNAoyZkRGOGZhNHFWQVlQLytCbHRBbStseWpOVEF6TUE0R0ExVWREd0VCL3dRRUF3SUZvREFUQmdOVkhTVUVEREFLCkJnZ3JCZ0VGQlFjREF6QU1CZ05WSFJNQkFmOEVBakFBTUFvR0NDcUdTTTQ5QkFNQ0EwZ0FNRVVDSUErWHZrblgKMEpxelQ0WDVqdEpFUG8xQjNpSEJRZUhMb043UnVXVE95SU85QWlFQXF6bWdmNDZKUFFkV05mOHZ1TEJlUmdJYQoxVHF6S25rV2dteVhFdmplS0ljPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="}},"2e27b6898d94d3e134f1b223f8342a7f4ea18e95e51271b6d64eb7319a08b855":{"keytype":"ecdsa","keyval":{"private":null,"public":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEf3dmn+ATN63G1xkiDPyshhISYmzsHrGXnWDDqkmqWVwLhqN8oV1IRSQLqMeHHxDB2MWSgPzo3zcRHzTJ699wTg=="}},"73c9c8cf155f7e4a4324ced1519461ceee185ce1405984f976ae3b8a4f332e43":{"keytype":"ecdsa","keyval":{"private":null,"public":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAElK9qIW4lHiVDx3BO+UdwsIj2hOcf4kdaJcgp4+e0oHCJuJd06m/3rP55/1HpQWZ3hGbFL4jgJD/2nHKo0hFClg=="}},"bd2c62bff4fa172fb40605fb2d8658d2b9c09e655b8ebb38f30550f5bd717eea":{"keytype":"ecdsa","keyval":{"private":null,"public":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuAvewzw4oXj7aWBDFMyeFen0FxZO8+wxOkPElvY8l4ODIFSWHYToggerpLMKrPKN6SkNA+toDn7ZJd61nQHRDw=="}}},"roles":{"root":{"keyids":["231efb776eb60d7a240a2b3deb3d458c32062cab05db69e62df838ac09214004"],"threshold":1},"snapshot":{"keyids":["bd2c62bff4fa172fb40605fb2d8658d2b9c09e655b8ebb38f30550f5bd717eea"],"threshold":1},"targets":{"keyids":["2e27b6898d94d3e134f1b223f8342a7f4ea18e95e51271b6d64eb7319a08b855"],"threshold":1},"timestamp":{"keyids":["73c9c8cf155f7e4a4324ced1519461ceee185ce1405984f976ae3b8a4f332e43"],"threshold":1}},"version":1},"signatures":[{"keyid":"231efb776eb60d7a240a2b3deb3d458c32062cab05db69e62df838ac09214004","method":"ecdsa","sig":"hnIYijab4LoGbz1NqdyfGDkOOczhvdFtBcxIFGPovNuGDihiQuOUhFbKD2nVrxEA+t9ZZ+vKIm7LpqYE7ULXgA=="}]}
{"signed":{"_type":"Root","consistent_snapshot":false,"expires":"2040-02-19T10:51:17.538343687Z","keys":{"446d15b6810b7d7a4f0678a3fd1302ca8a45fec900f05588f80a31e98744c54b":{"keytype":"ecdsa","keyval":{"private":null,"public":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE5APVHCLytTo+bbqaVXkvXWly/Gqi6Pj7dtGyyxAqi5Y1Q0Yd02n1sifC3jmAUdf4aDiJ8hiZQMNf3kCl00MZEw=="}},"8fdc4b4cff6c2387e34ecee7568eb1a26fb05ebfb751e99b925a4184243d5648":{"keytype":"ecdsa","keyval":{"private":null,"public":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAENwThOKUnYUoklHEBrX1JUfls/s5LG5sNG9iewiaNUzy2+Xbj5P6cALJzgmcHpDFVHq5QXW/trag4zjQvL6S7sQ=="}},"918b6904ce78ed3134205d3668260d55f9be64c78630da0ab6cbbc1d11db924c":{"keytype":"ecdsa","keyval":{"private":null,"public":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEbQKP+f2UCgbJre58NdV1hlaQZ7dZKrQJDxUmMSTTAcCnmj8rhMVN+8BAs+ZCvUSMZR9eFw9COcyYiZ/Oj05o2A=="}},"e958c0333d49fdf7dfba08c54fc01bff7319c6f23c1e3cd2f28bb9946a8ff670":{"keytype":"ecdsa-x509","keyval":{"private":null,"public":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJtVENDQVQrZ0F3SUJBZ0lRY0VVejkvbk9PbzVKRWhuNGNXQjZTekFLQmdncWhrak9QUVFEQWpBek1URXcKTHdZRFZRUURFeWhxZEMxa1pYWXViRzlqWVd3dVoyOW9ZWEppYjNJdWFXOHZiR2xpY21GeWVTOWlkWE41WW05NApNQjRYRFRJd01ESXlOREV3TlRFeE5Gb1hEVE13TURJeU1URXdOVEV4TkZvd016RXhNQzhHQTFVRUF4TW9hblF0ClpHVjJMbXh2WTJGc0xtZHZhR0Z5WW05eUxtbHZMMnhwWW5KaGNua3ZZblZ6ZVdKdmVEQlpNQk1HQnlxR1NNNDkKQWdFR0NDcUdTTTQ5QXdFSEEwSUFCREJhS2V5ZWc3M2prWTlXdEhwYk10c1JqMUpyQXh2WXJEcUIyV1JwUjMrdQoxMnVsbktwb1dpOXFYbzdkbEJQMDk2VkkwdFk5T1ludmlFTEhBajE5dmttak5UQXpNQTRHQTFVZER3RUIvd1FFCkF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUZCUWNEQXpBTUJnTlZIUk1CQWY4RUFqQUFNQW9HQ0NxR1NNNDkKQkFNQ0EwZ0FNRVVDSUhUM2JZUTBrdFp5eERIdlZHS0x3eXJVQ1djWGpwZUlLWHR2aE5ocmRzRWZBaUVBc1RTNApKcHNRcVI3UUg4TlYrQ0pRdUVKU3AxN2FJUm1wS0JSZ1puclc1ejQ9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K"}}},"roles":{"root":{"keyids":["e958c0333d49fdf7dfba08c54fc01bff7319c6f23c1e3cd2f28bb9946a8ff670"],"threshold":1},"snapshot":{"keyids":["8fdc4b4cff6c2387e34ecee7568eb1a26fb05ebfb751e99b925a4184243d5648"],"threshold":1},"targets":{"keyids":["446d15b6810b7d7a4f0678a3fd1302ca8a45fec900f05588f80a31e98744c54b"],"threshold":1},"timestamp":{"keyids":["918b6904ce78ed3134205d3668260d55f9be64c78630da0ab6cbbc1d11db924c"],"threshold":1}},"version":1},"signatures":[{"keyid":"e958c0333d49fdf7dfba08c54fc01bff7319c6f23c1e3cd2f28bb9946a8ff670","method":"ecdsa","sig":"/JrNrI8K6+F4yiq3ZKABrVYLJ7HyPLFkVn2op0ZCTzAVlo+hQo7hffV+wuJ7w44OXVLbmcHdOckVocPWQhyOyA=="}]}

View File

@ -1 +0,0 @@
{"signed":{"_type":"Snapshot","expires":"2020-03-14T11:40:40.159699242Z","meta":{"root":{"hashes":{"sha256":"m/o/32uww8VW3apHT9Xh+ib0KRseWOZlaWDw/tWXflI=","sha512":"QxS0hASJWIbZOugekW8e8k6Mo8wO5kqW0gHjTYdQ6Yildef+8fvaAJVv4B+y/pR1pz2wEKoaWN1EH+r9nzNVCA=="},"length":2429},"targets":{"hashes":{"sha256":"cEUxniqitBLAAopevwsIRuCPB/sL1t/Rgc1LvnKDj9c=","sha512":"ejO/EajI5U4/vbrkQ5O0yjOc91RB3dQOoNHMnc7JeLY4rEk3an2MU0II/LUYaRTKLgzFf//h7f1TDpKEKcxhVQ=="},"length":432}},"version":1},"signatures":[{"keyid":"bd2c62bff4fa172fb40605fb2d8658d2b9c09e655b8ebb38f30550f5bd717eea","method":"ecdsa","sig":"MbWydcENSegBhNio1M6xDW6Sq9hlxMtKP8jVN/N0zymUqOaPq4m3FzgEYls1NbuQ0Gj11K7NtdD5al74qWITLQ=="}]}

View File

@ -0,0 +1 @@
{"signed":{"_type":"Snapshot","expires":"2030-02-21T10:51:17.590339057Z","meta":{"root":{"hashes":{"sha256":"GeR/crf+6uM8Lzq6tZkcLyvunNAfW0XQqK/s/V6JK68=","sha512":"BnORZz1ECC4wQ+VYHNFeG6jnex0QphHMfEaHDbOYGsNHm0N/yrXvoQoLZEISXuSDmiRe8J9NE2n7uwDb0iYxyQ=="},"length":2448},"targets":{"hashes":{"sha256":"eVFLSe6gU1NqhE4NANnOdJTResuIy/+sDqoroLtaaKA=","sha512":"t8IBbWumWjx9ctAkqrvkAb34UctsAR3sJdA7Wv4mWPfSKC0nbIxX/U5tlKWD0VSYTsN/7M0O7odu7poyiRFuCw=="},"length":438}},"version":1},"signatures":[{"keyid":"8fdc4b4cff6c2387e34ecee7568eb1a26fb05ebfb751e99b925a4184243d5648","method":"ecdsa","sig":"nbYYy7rSCkRdZGmBsGHsXbjhW45Xa89kGzg7L3X/qk8ZZKU2+mGmbRxaL5EU3iFk2EHs85mLmY7Io4nIq4GORw=="}]}

View File

@ -1 +0,0 @@
{"signed":{"_type":"Targets","delegations":{"keys":{},"roles":[]},"expires":"2020-03-14T19:40:40.13723466+08:00","targets":{"1.0":{"hashes":{"sha256":"E1lggRW5RZnlZBY4usWu8d36p5u5YFfr9B68jTOs+Kc="},"length":527}},"version":2},"signatures":[{"keyid":"2e27b6898d94d3e134f1b223f8342a7f4ea18e95e51271b6d64eb7319a08b855","method":"ecdsa","sig":"SETP7J/FBtIL5cZVNg1ERjv7n1GD2WTBGqHe8wvHymAnKKicMYXtaRAfPWerKrNwG9Yl/1sjJV/Q2lH1SFkEAw=="}]}

View File

@ -0,0 +1 @@
{"signed":{"_type":"Targets","delegations":{"keys":{},"roles":[]},"expires":"2030-02-21T10:51:17.561005523Z","targets":{"latest-signed":{"hashes":{"sha256":"3Zej/m1yHFzwOrrA9Q4oSNxYP3xOQb85ECzrQu39GAg="},"length":527}},"version":2},"signatures":[{"keyid":"446d15b6810b7d7a4f0678a3fd1302ca8a45fec900f05588f80a31e98744c54b","method":"ecdsa","sig":"2Y9o2dzT/7D8NIUHYMlcILrt29fQC7TyqZCjBRGGRMPexUdQTkONHng+3saLPmixvQrJapP9c2dDoffmdWWFuQ=="}]}

View File

@ -1 +1 @@
{"signed":{"_type":"Timestamp","expires":"2020-03-14T11:40:40.19936068Z","meta":{"snapshot":{"hashes":{"sha256":"YvH2+0LXsb5wx6D0thpEQnW724V8LQotNzpRGSryjUY=","sha512":"hTjtW7akumqZb0roV/n7k1LkaBnNPed5yTRlwBf9Y/QoSafgOxi2KDYYNLcuYOZwNT2raq9yilFZ80DNl0qjkw=="},"length":683}},"version":1},"signatures":[{"keyid":"73c9c8cf155f7e4a4324ced1519461ceee185ce1405984f976ae3b8a4f332e43","method":"ecdsa","sig":"nWv4Pyhjdmx0jEyIejjDqEAUQ5SlOGWUKs8xAnsEOO92DMZNa/GAYaRo9TT0kdI8rgrF+NHmCAGUXy/RRRXjdw=="}]}
{"signed":{"_type":"Timestamp","expires":"2030-02-21T10:51:17.618848442Z","meta":{"snapshot":{"hashes":{"sha256":"8OktzV/LWHLYl2N9mRsq+YkUCvNEeXBqdDxgIWsDqTs=","sha512":"rZPSDLEX7kBqBPwU7rf/4buWf6bPGoyARV1rlj9uxbSU8P2b5ltACZscoZuQz+Qj57PgPpj8y8GMcGtk883b5A=="},"length":683}},"version":1},"signatures":[{"keyid":"918b6904ce78ed3134205d3668260d55f9be64c78630da0ab6cbbc1d11db924c","method":"ecdsa","sig":"RUDVZgaQvol/97rkHr6pV8QIC1RZnrZ/3O1eQpMIJSR6BnCADmQFN9NUjoaWORlgjCSp2NH2AfHMNY5cHBn9Pg=="}]}