Add new environment variables for setting client identity for use with test.World.

Testing clients should now use CAMLI_CLIENT_IDENTITY,
CAMLI_DISABLE_CLIENT_CONFIG_FILE (both new) and existing
CAMLI_SECRET_RING, set using the new test.World accessors.

Change-Id: I9fc0571b008f033674466bbc98129ae1919a0640
This commit is contained in:
Brad Fitzpatrick 2014-01-20 13:54:42 -08:00
parent a384ff188d
commit 9abba638a0
3 changed files with 26 additions and 5 deletions

View File

@ -105,10 +105,16 @@ CAMLI_FAST_DEV (bool):
Used by dev/demo.sh for giving presentations with devcam server/put/etc
for faster pre-built builds, without calling make.go.
CAMLI_CLIENT_IDENTITY (string):
Optional GPG identity to use, taking precedence over config files.
CAMLI_SECRET_RING (string):
Path to the GPG secret keyring, which is otherwise set by identitySecretRing
in the server config, and secretRing in the client config.
CAMLI_DISABLE_CLIENT_CONFIG_FILE (bool):
If set, the pkg/client code will never use the on-disk config file.
CAMLI_TRACK_FS_STATS (bool):
Enable operation counts for fuse filesystem.

View File

@ -358,11 +358,14 @@ func (c *Client) SignerPublicKeyBlobref() blob.Ref {
}
func (c *Client) initSignerPublicKeyBlobref() {
keyId := os.Getenv("CAMLI_CLIENT_IDENTITY")
if keyId == "" {
configOnce.Do(parseConfig)
keyId := config.Identity
keyId = config.Identity
if keyId == "" {
log.Fatalf("No 'identity' key in JSON configuration file %q; have you run \"camput init\"?", osutil.UserClientConfigPath())
}
}
keyRing := c.SecretRingFile()
if !fileExists(keyRing) {
log.Fatalf("Could not find keyId %q, because secret ring file %q does not exist.", keyId, keyRing)

View File

@ -176,8 +176,8 @@ func (w *World) CmdWithEnv(binary string, env []string, args ...string) *exec.Cm
"CAMLI_CONFIG_DIR=" + clientConfigDir,
// Respected by env expansions in config/dev-client-dir/client-config.json:
"CAMLI_SERVER=" + w.ServerBaseURL(),
"CAMLI_SECRET_RING=" + filepath.Join(w.camRoot, "pkg", "jsonsign", "testdata", "test-secring.gpg"),
"CAMLI_KEYID=26F5ABDA",
"CAMLI_SECRET_RING=" + w.SecretRingFile(),
"CAMLI_KEYID=" + w.ClientIdentity(),
"CAMLI_AUTH=userpass:testuser:passTestWorld",
}, env...)
default:
@ -240,3 +240,15 @@ func MustRunCmd(t *testing.T, c *exec.Cmd) string {
}
return out
}
// ClientIdentity returns the GPG identity to use in World tests, suitable
// for setting in CAMLI_CLIENT_IDENTITY.
func (w *World) ClientIdentity() string {
return "26F5ABDA"
}
// SecretRingFile returns the GnuPG secret ring, suitable for setting
// in CAMLI_SECRET_RING.
func (w *World) SecretRingFile() string {
return filepath.Join(w.camRoot, "pkg", "jsonsign", "testdata", "test-secring.gpg")
}