MCPcopy Create free account
hub / github.com/docker/cli / TestValidateKeyArgs

Function TestValidateKeyArgs

cmd/docker-trust/trust/key_generate_test.go:104–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestValidateKeyArgs(t *testing.T) {
105 pubKeyCWD := t.TempDir()
106
107 err := validateKeyArgs("a", pubKeyCWD)
108 assert.NilError(t, err)
109
110 err = validateKeyArgs("a/b", pubKeyCWD)
111 assert.Error(t, err, "key name \"a/b\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character")
112
113 err = validateKeyArgs("-", pubKeyCWD)
114 assert.Error(t, err, "key name \"-\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character")
115
116 assert.NilError(t, os.WriteFile(filepath.Join(pubKeyCWD, "a.pub"), []byte("abc"), notary.PrivExecPerms))
117 err = validateKeyArgs("a", pubKeyCWD)
118 assert.Error(t, err, fmt.Sprintf("public key file already exists: \"%s\"", filepath.Join(pubKeyCWD, "a.pub")))
119
120 err = validateKeyArgs("a", "/random/dir/")
121 assert.Error(t, err, "public key path does not exist: \"/random/dir/\"")
122}

Callers

nothing calls this directly

Calls 2

validateKeyArgsFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…