bug: logout cannot handle named contexts despite documented usage
Summary
microcks logout CONTEXT is documented as supporting a named context, but the implementation passes the provided argument directly to LocalConfig.RemoveToken. That function searches LocalConfig.Users by user name, while login --name <name> stores the user under the server URL and stores the friendly name only in ContextRef.Name.
As a result, logging in with a named context works, but logging out by that same context name fails and leaves the auth and refresh tokens in the local config.
Evidence from the code
cmd/login.gostores the user withName: server, then stores the named context withName: ctxNameandUser: server.cmd/logout.goreadscontext := args[0]and callslocalCfg.RemoveToken(context)directly.pkg/config/localconfig.goimplementsRemoveTokenby comparingu.Name == serverName, so a context alias such asstagingwill not match the stored user name such ashttps://microcks.example.
Reproduction
- Log in with a named context:
microcks login https://microcks.example --name staging
- Try to log out using the documented named context form:
microcks logout staging
Actual behavior
The command fails with a message like:
Context staging does not exist
The token entry stored under the server URL remains in the config file.
Expected behavior
microcks logout staging should resolve the context name first, find the referenced user/server entry, and clear the associated auth and refresh tokens. If the CLI also wants to keep accepting raw server URLs, it can support both forms, but the documented named-context form should work.
Impact
This affects a core authentication workflow. Users who use named contexts can believe they are logging out, but the CLI cannot clear their tokens unless they know to pass the underlying server URL instead of the context name.