File: token.bats

package info (click to toggle)
docker-registry 2.8.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,148 kB
  • sloc: sh: 331; makefile: 82
file content (129 lines) | stat: -rw-r--r-- 2,783 bytes parent folder | download | duplicates (6)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env bats

# This tests contacting a registry using a token server

load helpers

user="testuser"
password="testpassword"
base="hello-world"

@test "Test token server login" {
	login localregistry:5554
}

@test "Test token server bad login" {
	docker_t_login -u "testuser" -p "badpassword" localregistry:5554
	[ "$status" -ne 0 ]

	docker_t_login -u "baduser" -p "testpassword" localregistry:5554
	[ "$status" -ne 0 ]
}

@test "Test push and pull with token auth" {
	login localregistry:5555
	image="localregistry:5555/testuser/token"
	build $image "$base:latest"

	run docker_t push $image
	echo $output
	[ "$status" -eq 0 ]

	docker_t rmi $image

	docker_t pull $image
}

@test "Test push and pull with token auth wrong namespace" {
	login localregistry:5555
	image="localregistry:5555/notuser/token"
	build $image "$base:latest"

	run docker_t push $image
	[ "$status" -ne 0 ]
}

@test "Test oauth token server login" {
	version_check docker "$GOLEM_DIND_VERSION" "1.11.0"

	login_oauth localregistry:5557
}

@test "Test oauth token server bad login" {
	version_check docker "$GOLEM_DIND_VERSION" "1.11.0"

	docker_t_login -u "testuser" -p "badpassword" -e $email localregistry:5557
	[ "$status" -ne 0 ]

	docker_t_login -u "baduser" -p "testpassword" -e $email localregistry:5557
	[ "$status" -ne 0 ]
}

@test "Test oauth push and pull with token auth" {
	version_check docker "$GOLEM_DIND_VERSION" "1.11.0"

	login_oauth localregistry:5558
	image="localregistry:5558/testuser/token"
	build $image "$base:latest"

	run docker_t push $image
	echo $output
	[ "$status" -eq 0 ]

	docker_t rmi $image

	docker_t pull $image
}

@test "Test oauth push and build with token auth" {
	version_check docker "$GOLEM_DIND_VERSION" "1.11.0"

	login_oauth localregistry:5558
	image="localregistry:5558/testuser/token-build"
	tempImage $image

	run docker_t push $image
	echo $output
	[ "$status" -eq 0 ]
	has_digest "$output"

	docker_t rmi $image

	image2="localregistry:5558/testuser/token-build-2"
	run build $image2 $image
	echo $output
	[ "$status" -eq 0 ]

	run docker_t push $image2
	echo $output
	[ "$status" -eq 0 ]
	has_digest "$output"

}

@test "Test oauth push and pull with token auth wrong namespace" {
	version_check docker "$GOLEM_DIND_VERSION" "1.11.0"

	login_oauth localregistry:5558
	image="localregistry:5558/notuser/token"
	build $image "$base:latest"

	run docker_t push $image
	[ "$status" -ne 0 ]
}

@test "Test oauth with v1 search" {
	version_check docker "$GOLEM_DIND_VERSION" "1.12.0"

	run docker_t search localregistry:5600/testsearch
	[ "$status" -ne 0 ]

	login_oauth localregistry:5600

	run docker_t search localregistry:5600/testsearch
	echo $output
	[ "$status" -eq 0 ]

	echo $output | grep "testsearch-1"
	echo $output | grep "testsearch-2"
}