diff --git a/cmd/skopeo/login_test.go b/cmd/skopeo/login_test.go new file mode 100644 index 0000000000..f92ceb7a9c --- /dev/null +++ b/cmd/skopeo/login_test.go @@ -0,0 +1,18 @@ +package main + +import ( + "path/filepath" + "testing" +) + +func TestLogin(t *testing.T) { + dir := t.TempDir() + authFile := filepath.Join(dir, "auth.json") + compatAuthFile := filepath.Join(dir, "config.json") + + // Just a trivial smoke-test exercising one error-handling path. + // We can’t test full operation without a registry, unit tests should mostly + // exist in c/common/pkg/auth, not here. + out, err := runSkopeo("login", "--authfile", authFile, "--compat-auth-file", compatAuthFile, "example.com") + assertTestFailed(t, out, err, "options for paths to the credential file and to the Docker-compatible credential file can not be set simultaneously") +} diff --git a/cmd/skopeo/logout_test.go b/cmd/skopeo/logout_test.go new file mode 100644 index 0000000000..ecb72caae5 --- /dev/null +++ b/cmd/skopeo/logout_test.go @@ -0,0 +1,25 @@ +package main + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestLogout(t *testing.T) { + dir := t.TempDir() + authFile := filepath.Join(dir, "auth.json") + compatAuthFile := filepath.Join(dir, "config.json") + + // Just a trivial smoke-test exercising one error-handling path. + // We can’t test full operation without a registry, unit tests should mostly + // exist in c/common/pkg/auth, not here. + err := os.WriteFile(authFile, []byte("{}"), 0o700) + require.NoError(t, err) + err = os.WriteFile(compatAuthFile, []byte("{}"), 0o700) + require.NoError(t, err) + out, err := runSkopeo("logout", "--authfile", authFile, "--compat-auth-file", compatAuthFile, "example.com") + assertTestFailed(t, out, err, "options for paths to the credential file and to the Docker-compatible credential file can not be set simultaneously") +} diff --git a/docs/skopeo-login.1.md b/docs/skopeo-login.1.md index e4bd260bbf..28189d9c18 100644 --- a/docs/skopeo-login.1.md +++ b/docs/skopeo-login.1.md @@ -36,6 +36,10 @@ Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` +**--compat-auth-file**=*path* + +Instead of updating the default credentials file, update the one at *path*, and use a Docker-compatible format. + **--get-login** Return the logged-in user for the registry. Return error if no login is found. diff --git a/docs/skopeo-logout.1.md b/docs/skopeo-logout.1.md index 045b9fde87..1837bb447a 100644 --- a/docs/skopeo-logout.1.md +++ b/docs/skopeo-logout.1.md @@ -23,6 +23,10 @@ Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` +**--compat-auth-file**=*path* + +Instead of updating the default credentials file, update the one at *path*, and use a Docker-compatible format. + **--all**, **-a** Remove the cached credentials for all registries in the auth file