Skip to content

Commit

Permalink
rename zot
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Aug 25, 2023
1 parent 2c2b597 commit 6f9f3c2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
16 changes: 8 additions & 8 deletions test/e2e/internal/utils/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var Host string
// FallbackHost points to the registry service where fallback E2E specs will be run against.
var FallbackHost string

// ZotHost points to the zot service where E2E specs will be run against.
var ZotHost string
// ZOTHost points to the zot service where E2E specs will be run against.
var ZOTHost string

func init() {
Host = os.Getenv(RegHostKey)
Expand All @@ -62,12 +62,12 @@ func init() {
panic(err)
}

ZotHost = os.Getenv(ZotHostKey)
if ZotHost == "" {
ZotHost = "localhost:7000"
fmt.Fprintf(os.Stderr, "cannot find zot host name in %s, using %s instead\n", ZotHostKey, ZotHost)
ZOTHost = os.Getenv(ZOTHostKey)
if ZOTHost == "" {
ZOTHost = "localhost:7000"
fmt.Fprintf(os.Stderr, "cannot find zot host name in %s, using %s instead\n", ZOTHostKey, ZOTHost)
}
ref.Registry = ZotHost
ref.Registry = ZOTHost
if err := ref.ValidateRegistry(); err != nil {
panic(err)
}
Expand Down Expand Up @@ -124,7 +124,7 @@ func init() {
gomega.Expect(cmd.Run()).ShouldNot(gomega.HaveOccurred())
cmd = exec.Command(ORASPath, "login", FallbackHost, "-u", Username, "-p", Password)
gomega.Expect(cmd.Run()).ShouldNot(gomega.HaveOccurred())
cmd = exec.Command(ORASPath, "login", ZotHost, "-u", Username, "-p", Password)
cmd = exec.Command(ORASPath, "login", ZOTHost, "-u", Username, "-p", Password)
gomega.Expect(cmd.Run()).ShouldNot(gomega.HaveOccurred())
})
}
2 changes: 1 addition & 1 deletion test/e2e/internal/utils/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
// env
RegHostKey = "ORAS_REGISTRY_HOST"
FallbackRegHostKey = "ORAS_REGISTRY_FALLBACK_HOST"
ZotHostKey = "ZOT_REGISTRY_HOST"
ZOTHostKey = "ZOT_REGISTRY_HOST"
)

var (
Expand Down
40 changes: 20 additions & 20 deletions test/e2e/suite/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,38 @@ import (
var _ = Describe("Common registry user", Ordered, func() {
When("logging out", Ordered, func() {
It("should use logout command to logout", func() {
ORAS("logout", ZotHost, "--registry-config", AuthConfigPath).Exec()
ORAS("logout", ZOTHost, "--registry-config", AuthConfigPath).Exec()
})

It("should run commands without logging in", func() {
RunWithoutLogin("attach", ZotHost+"/repo:tag", "-a", "test=true", "--artifact-type", "doc/example")
ORAS("copy", ZotHost+"/repo:from", ZotHost+"/repo:to", "--from-registry-config", AuthConfigPath, "--to-registry-config", AuthConfigPath).
RunWithoutLogin("attach", ZOTHost+"/repo:tag", "-a", "test=true", "--artifact-type", "doc/example")
ORAS("copy", ZOTHost+"/repo:from", ZOTHost+"/repo:to", "--from-registry-config", AuthConfigPath, "--to-registry-config", AuthConfigPath).
ExpectFailure().
MatchErrKeyWords("Error:", "credential required").
WithDescription("fail without logging in").Exec()
RunWithoutLogin("discover", ZotHost+"/repo:tag")
RunWithoutLogin("push", "-a", "key=value", ZotHost+"/repo:tag")
RunWithoutLogin("pull", ZotHost+"/repo:tag")
RunWithoutLogin("manifest", "fetch", ZotHost+"/repo:tag")
RunWithoutLogin("blob", "delete", ZotHost+"/repo@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
RunWithoutLogin("blob", "push", ZotHost+"/repo", WriteTempFile("blob", "test"))
RunWithoutLogin("tag", ZotHost+"/repo:tag", "tag1")
RunWithoutLogin("repo", "ls", ZotHost)
RunWithoutLogin("repo", "tags", RegistryRef(ZotHost, "repo", ""))
RunWithoutLogin("manifest", "fetch-config", ZotHost+"/repo:tag")
RunWithoutLogin("discover", ZOTHost+"/repo:tag")
RunWithoutLogin("push", "-a", "key=value", ZOTHost+"/repo:tag")
RunWithoutLogin("pull", ZOTHost+"/repo:tag")
RunWithoutLogin("manifest", "fetch", ZOTHost+"/repo:tag")
RunWithoutLogin("blob", "delete", ZOTHost+"/repo@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
RunWithoutLogin("blob", "push", ZOTHost+"/repo", WriteTempFile("blob", "test"))
RunWithoutLogin("tag", ZOTHost+"/repo:tag", "tag1")
RunWithoutLogin("repo", "ls", ZOTHost)
RunWithoutLogin("repo", "tags", RegistryRef(ZOTHost, "repo", ""))
RunWithoutLogin("manifest", "fetch-config", ZOTHost+"/repo:tag")
})
})

When("logging in", func() {
It("should use basic auth", func() {
ORAS("login", ZotHost, "-u", Username, "-p", Password, "--registry-config", AuthConfigPath).
ORAS("login", ZOTHost, "-u", Username, "-p", Password, "--registry-config", AuthConfigPath).
WithTimeOut(20*time.Second).
MatchContent("Login Succeeded\n").
MatchErrKeyWords("WARNING", "Using --password via the CLI is insecure", "Use --password-stdin").Exec()
})

It("should fail if no username input", func() {
ORAS("login", ZotHost, "--registry-config", AuthConfigPath).
ORAS("login", ZOTHost, "--registry-config", AuthConfigPath).
WithTimeOut(20 * time.Second).
WithInput(strings.NewReader("")).
MatchKeyWords("username:").
Expand All @@ -67,37 +67,37 @@ var _ = Describe("Common registry user", Ordered, func() {
})

It("should fail if no password input", func() {
ORAS("login", ZotHost, "--registry-config", AuthConfigPath).
ORAS("login", ZOTHost, "--registry-config", AuthConfigPath).
WithTimeOut(20*time.Second).
MatchKeyWords("Username: ", "Password: ").
WithInput(strings.NewReader(fmt.Sprintf("%s\n", Username))).ExpectFailure().Exec()
})

It("should fail if password is empty", func() {
ORAS("login", ZotHost, "--registry-config", AuthConfigPath).
ORAS("login", ZOTHost, "--registry-config", AuthConfigPath).
WithTimeOut(20*time.Second).
MatchKeyWords("Username: ", "Password: ").
MatchErrKeyWords("Error: password required").
WithInput(strings.NewReader(fmt.Sprintf("%s\n\n", Username))).ExpectFailure().Exec()
})

It("should fail if no token input", func() {
ORAS("login", ZotHost, "--registry-config", AuthConfigPath).
ORAS("login", ZOTHost, "--registry-config", AuthConfigPath).
WithTimeOut(20*time.Second).
MatchKeyWords("Username: ", "Token: ").
WithInput(strings.NewReader("\n")).ExpectFailure().Exec()
})

It("should fail if token is empty", func() {
ORAS("login", ZotHost, "--registry-config", AuthConfigPath).
ORAS("login", ZOTHost, "--registry-config", AuthConfigPath).
WithTimeOut(20*time.Second).
MatchKeyWords("Username: ", "Token: ").
MatchErrKeyWords("Error: token required").
WithInput(strings.NewReader("\n\n")).ExpectFailure().Exec()
})

It("should use prompted input", func() {
ORAS("login", ZotHost, "--registry-config", AuthConfigPath).
ORAS("login", ZOTHost, "--registry-config", AuthConfigPath).
WithTimeOut(20*time.Second).
WithInput(strings.NewReader(fmt.Sprintf("%s\n%s\n", Username, Password))).
MatchKeyWords("Username: ", "Password: ", "Login Succeeded\n").Exec()
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/suite/scenario/oci_artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ var _ = Describe("OCI artifact users:", Ordered, func() {
pulledManifest := "packed.json"
pullRoot := "pulled"
It("should push and pull an artifact", func() {
ORAS("push", RegistryRef(ZotHost, repo, tag), "--artifact-type", "test/artifact", foobar.FileLayerNames[0], foobar.FileLayerNames[1], foobar.FileLayerNames[2], "-v", "--export-manifest", pulledManifest).
ORAS("push", RegistryRef(ZOTHost, repo, tag), "--artifact-type", "test/artifact", foobar.FileLayerNames[0], foobar.FileLayerNames[1], foobar.FileLayerNames[2], "-v", "--export-manifest", pulledManifest).
MatchStatus(foobar.FileStateKeys, true, 3).
WithWorkDir(tempDir).
WithDescription("push with manifest exported").Exec()

fetched := ORAS("manifest", "fetch", RegistryRef(ZotHost, repo, tag)).Exec()
fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec()
MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout)

ORAS("pull", RegistryRef(ZotHost, repo, tag), "-v", "-o", pullRoot).
ORAS("pull", RegistryRef(ZOTHost, repo, tag), "-v", "-o", pullRoot).
MatchStatus(foobar.FileStateKeys, true, 3).
WithWorkDir(tempDir).
WithDescription("pull artFiles with config").Exec()
Expand All @@ -58,18 +58,18 @@ var _ = Describe("OCI artifact users:", Ordered, func() {
})

It("should attach and pull an artifact", func() {
subject := RegistryRef(ZotHost, repo, tag)
subject := RegistryRef(ZOTHost, repo, tag)
ORAS("attach", subject, "--artifact-type", "test/artifact1", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "-v", "--export-manifest", pulledManifest).
MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1).
WithWorkDir(tempDir).
WithDescription("attach with manifest exported").Exec()

session := ORAS("discover", subject, "-o", "json").Exec()
digest := string(Binary("jq", "-r", ".manifests[].digest").WithInput(session.Out).Exec().Out.Contents())
fetched := ORAS("manifest", "fetch", RegistryRef(ZotHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec()
fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec()
MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout)

ORAS("pull", RegistryRef(ZotHost, repo, digest), "-v", "-o", pullRoot).
ORAS("pull", RegistryRef(ZOTHost, repo, digest), "-v", "-o", pullRoot).
MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1).
WithWorkDir(tempDir).
WithDescription("pull attached artifact").Exec()
Expand All @@ -84,10 +84,10 @@ var _ = Describe("OCI artifact users:", Ordered, func() {

session = ORAS("discover", subject, "-o", "json", "--artifact-type", "test/artifact2").Exec()
digest = string(Binary("jq", "-r", ".manifests[].digest").WithInput(session.Out).Exec().Out.Contents())
fetched = ORAS("manifest", "fetch", RegistryRef(ZotHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec()
fetched = ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec()
MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout)

ORAS("pull", RegistryRef(ZotHost, repo, string(digest)), "-v", "-o", pullRoot, "--include-subject").
ORAS("pull", RegistryRef(ZOTHost, repo, string(digest)), "-v", "-o", pullRoot, "--include-subject").
MatchStatus(append(foobar.FileStateKeys, foobar.AttachFileStateKey), true, 4).
WithWorkDir(tempDir).
WithDescription("pull attached artifact and subject").Exec()
Expand Down

0 comments on commit 6f9f3c2

Please sign in to comment.