-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathauth_test.go
More file actions
37 lines (31 loc) · 836 Bytes
/
auth_test.go
File metadata and controls
37 lines (31 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package e2e
import (
"testing"
"github.com/docker/cli/e2e/internal/registry"
"github.com/docker/cli/internal/test/command"
)
func runDockerCommand(t *testing.T, args ...string) {
cmd := command.NewDockerCommand(t, args...)
cmd.Assert()
}
func TestAuthorizedPullPush(t *testing.T) {
const (
username = "testuser"
password = "testpassword"
)
reg, err := registry.NewV2(
registry.WithAuth(username, password),
)
if err != nil {
t.Fatalf("Failed to start registry: %v", err)
}
defer reg.Stop()
repo := reg.RepoName("private/alpine")
// docker login
runDockerCommand(t, "login", reg.Host(), "-u", username, "-p", password)
runDockerCommand(t, "pull", "alpine")
runDockerCommand(t, "tag", "alpine", repo)
runDockerCommand(t, "push", repo)
runDockerCommand(t, "rmi", repo)
runDockerCommand(t, "pull", repo)
}