@@ -2,7 +2,6 @@ package container
22
33import (
44 "bytes"
5- "fmt"
65 "io"
76 "math/rand"
87 "os/exec"
@@ -90,104 +89,6 @@ func TestRunInvalidEntrypointWithAutoremove(t *testing.T) {
9089 }
9190}
9291
93- func TestRunWithContentTrust (t * testing.T ) {
94- skip .If (t , environment .RemoteDaemon ())
95-
96- dir := fixtures .SetupConfigFile (t )
97- defer dir .Remove ()
98- image := fixtures .CreateMaskedTrustedRemoteImage (t , registryPrefix , "trust-run" , "latest" )
99-
100- defer func () {
101- icmd .RunCommand ("docker" , "image" , "rm" , image ).Assert (t , icmd .Success )
102- }()
103-
104- result := icmd .RunCmd (
105- icmd .Command ("docker" , "run" , image ),
106- fixtures .WithConfig (dir .Path ()),
107- fixtures .WithTrust ,
108- fixtures .WithNotary ,
109- )
110- result .Assert (t , icmd.Expected {
111- Err : fmt .Sprintf ("Tagging %s@sha" , image [:len (image )- 7 ]),
112- })
113- }
114-
115- func TestUntrustedRun (t * testing.T ) {
116- dir := fixtures .SetupConfigFile (t )
117- defer dir .Remove ()
118- image := registryPrefix + "/alpine:untrusted"
119- // tag the image and upload it to the private registry
120- icmd .RunCommand ("docker" , "tag" , fixtures .AlpineImage , image ).Assert (t , icmd .Success )
121- defer func () {
122- icmd .RunCommand ("docker" , "image" , "rm" , image ).Assert (t , icmd .Success )
123- }()
124-
125- // try trusted run on untrusted tag
126- result := icmd .RunCmd (
127- icmd .Command ("docker" , "run" , image ),
128- fixtures .WithConfig (dir .Path ()),
129- fixtures .WithTrust ,
130- fixtures .WithNotary ,
131- )
132- result .Assert (t , icmd.Expected {
133- ExitCode : 125 ,
134- Err : "does not have trust data for" ,
135- })
136- }
137-
138- func TestTrustedRunFromBadTrustServer (t * testing.T ) {
139- evilImageName := registryPrefix + "/evil-alpine:latest"
140- dir := fixtures .SetupConfigFile (t )
141- defer dir .Remove ()
142-
143- // tag the image and upload it to the private registry
144- icmd .RunCmd (icmd .Command ("docker" , "tag" , fixtures .AlpineImage , evilImageName ),
145- fixtures .WithConfig (dir .Path ()),
146- ).Assert (t , icmd .Success )
147- icmd .RunCmd (icmd .Command ("docker" , "image" , "push" , evilImageName ),
148- fixtures .WithConfig (dir .Path ()),
149- fixtures .WithPassphrase ("root_password" , "repo_password" ),
150- fixtures .WithTrust ,
151- fixtures .WithNotary ,
152- ).Assert (t , icmd .Success )
153- icmd .RunCmd (icmd .Command ("docker" , "image" , "rm" , evilImageName )).Assert (t , icmd .Success )
154-
155- // try run
156- icmd .RunCmd (icmd .Command ("docker" , "run" , evilImageName ),
157- fixtures .WithConfig (dir .Path ()),
158- fixtures .WithTrust ,
159- fixtures .WithNotary ,
160- ).Assert (t , icmd .Success )
161- icmd .RunCmd (icmd .Command ("docker" , "image" , "rm" , evilImageName )).Assert (t , icmd .Success )
162-
163- // init a client with the evil-server and a new trust dir
164- evilNotaryDir := fixtures .SetupConfigWithNotaryURL (t , "evil-test" , fixtures .EvilNotaryURL )
165- defer evilNotaryDir .Remove ()
166-
167- // tag the same image and upload it to the private registry but signed with evil notary server
168- icmd .RunCmd (icmd .Command ("docker" , "tag" , fixtures .AlpineImage , evilImageName ),
169- fixtures .WithConfig (evilNotaryDir .Path ()),
170- ).Assert (t , icmd .Success )
171- icmd .RunCmd (icmd .Command ("docker" , "image" , "push" , evilImageName ),
172- fixtures .WithConfig (evilNotaryDir .Path ()),
173- fixtures .WithPassphrase ("root_password" , "repo_password" ),
174- fixtures .WithTrust ,
175- fixtures .WithNotaryServer (fixtures .EvilNotaryURL ),
176- ).Assert (t , icmd .Success )
177- icmd .RunCmd (icmd .Command ("docker" , "image" , "rm" , evilImageName )).Assert (t , icmd .Success )
178-
179- // try running with the original client from the evil notary server. This should failed
180- // because the new root is invalid
181- icmd .RunCmd (icmd .Command ("docker" , "run" , evilImageName ),
182- fixtures .WithConfig (dir .Path ()),
183- fixtures .WithTrust ,
184- fixtures .WithNotaryServer (fixtures .EvilNotaryURL ),
185- ).Assert (t , icmd.Expected {
186- ExitCode : 125 ,
187- Err : "could not rotate trust to a new trusted root" ,
188- })
189- }
190-
19192// TODO: create this with registry API instead of engine API
19293func createRemoteImage (t * testing.T ) string {
19394 t .Helper ()
0 commit comments