mirror of
https://github.com/containers/skopeo.git
synced 2025-07-11 05:33:42 +00:00
Test both imageOptions and imageDestOptions in TestTLSVerifyFlags
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
2a98df6b12
commit
bb447f2f1e
@ -170,6 +170,8 @@ func TestImageDestOptionsNewSystemContext(t *testing.T) {
|
|||||||
BigFilesTemporaryDir: "/srv",
|
BigFilesTemporaryDir: "/srv",
|
||||||
}, res)
|
}, res)
|
||||||
|
|
||||||
|
// Global/per-command tlsVerify behavior is tested in TestTLSVerifyFlags.
|
||||||
|
|
||||||
// Invalid option values in imageOptions
|
// Invalid option values in imageOptions
|
||||||
opts = fakeImageDestOptions(t, "dest-", []string{}, []string{"--dest-creds", ""})
|
opts = fakeImageDestOptions(t, "dest-", []string{}, []string{"--dest-creds", ""})
|
||||||
_, err = opts.newSystemContext()
|
_, err = opts.newSystemContext()
|
||||||
@ -177,6 +179,28 @@ func TestImageDestOptionsNewSystemContext(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTLSVerifyFlags(t *testing.T) {
|
func TestTLSVerifyFlags(t *testing.T) {
|
||||||
|
type systemContextOpts interface { // Either *imageOptions or *imageDestOptions
|
||||||
|
newSystemContext() (*types.SystemContext, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, creator := range []struct {
|
||||||
|
name string
|
||||||
|
newOpts func(globalFlags, cmdFlags []string) systemContextOpts
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"imageFlags",
|
||||||
|
func(globalFlags, cmdFlags []string) systemContextOpts {
|
||||||
|
return fakeImageOptions(t, "dest-", globalFlags, cmdFlags)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"imageDestFlags",
|
||||||
|
func(globalFlags, cmdFlags []string) systemContextOpts {
|
||||||
|
return fakeImageDestOptions(t, "dest-", globalFlags, cmdFlags)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
t.Run(creator.name, func(t *testing.T) {
|
||||||
for _, c := range []struct {
|
for _, c := range []struct {
|
||||||
global, cmd string
|
global, cmd string
|
||||||
expectedDocker types.OptionalBool
|
expectedDocker types.OptionalBool
|
||||||
@ -200,12 +224,14 @@ func TestTLSVerifyFlags(t *testing.T) {
|
|||||||
if c.cmd != "" {
|
if c.cmd != "" {
|
||||||
cmdFlags = append(cmdFlags, "--dest-tls-verify="+c.cmd)
|
cmdFlags = append(cmdFlags, "--dest-tls-verify="+c.cmd)
|
||||||
}
|
}
|
||||||
opts := fakeImageOptions(t, "dest-", globalFlags, cmdFlags)
|
opts := creator.newOpts(globalFlags, cmdFlags)
|
||||||
res, err := opts.newSystemContext()
|
res, err := opts.newSystemContext()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, c.expectedDocker, res.DockerInsecureSkipTLSVerify, "%#v", c)
|
assert.Equal(t, c.expectedDocker, res.DockerInsecureSkipTLSVerify, "%#v", c)
|
||||||
assert.Equal(t, c.expectedDockerDaemon, res.DockerDaemonInsecureSkipTLSVerify, "%#v", c)
|
assert.Equal(t, c.expectedDockerDaemon, res.DockerDaemonInsecureSkipTLSVerify, "%#v", c)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseManifestFormat(t *testing.T) {
|
func TestParseManifestFormat(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user