* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
37 lines
780 B
Go
37 lines
780 B
Go
/*
|
|
* Please refer to the LICENSE file in the root directory of the project.
|
|
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
|
*/
|
|
|
|
package registries
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestDigestFromDockerHub(t *testing.T) {
|
|
|
|
testImage := Image{Domain: "docker.io", Path: "library/alpine", Tag: "latest"}
|
|
r, err := CreateRegistryClient("", "", "docker.io", true, false)
|
|
if err != nil {
|
|
t.Fatalf("Could not get client: %s", err)
|
|
}
|
|
|
|
digestUrl := r.GetDigestUrl(testImage)
|
|
|
|
// Get token.
|
|
token, err := r.Token(digestUrl)
|
|
if err != nil || token == "" {
|
|
t.Fatalf("Could not get token: %s", err)
|
|
}
|
|
|
|
d, err := r.ImageManifest(testImage, token)
|
|
if err != nil {
|
|
t.Fatalf("Could not get digest: %s", err)
|
|
}
|
|
|
|
if d == nil {
|
|
t.Error("Empty digest received")
|
|
}
|
|
}
|