mirror of https://github.com/perkeep/perkeep.git
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:
parent
a384ff188d
commit
9abba638a0
|
@ -105,10 +105,16 @@ CAMLI_FAST_DEV (bool):
|
||||||
Used by dev/demo.sh for giving presentations with devcam server/put/etc
|
Used by dev/demo.sh for giving presentations with devcam server/put/etc
|
||||||
for faster pre-built builds, without calling make.go.
|
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):
|
CAMLI_SECRET_RING (string):
|
||||||
Path to the GPG secret keyring, which is otherwise set by identitySecretRing
|
Path to the GPG secret keyring, which is otherwise set by identitySecretRing
|
||||||
in the server config, and secretRing in the client config.
|
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):
|
CAMLI_TRACK_FS_STATS (bool):
|
||||||
Enable operation counts for fuse filesystem.
|
Enable operation counts for fuse filesystem.
|
||||||
|
|
||||||
|
|
|
@ -358,10 +358,13 @@ func (c *Client) SignerPublicKeyBlobref() blob.Ref {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) initSignerPublicKeyBlobref() {
|
func (c *Client) initSignerPublicKeyBlobref() {
|
||||||
configOnce.Do(parseConfig)
|
keyId := os.Getenv("CAMLI_CLIENT_IDENTITY")
|
||||||
keyId := config.Identity
|
|
||||||
if keyId == "" {
|
if keyId == "" {
|
||||||
log.Fatalf("No 'identity' key in JSON configuration file %q; have you run \"camput init\"?", osutil.UserClientConfigPath())
|
configOnce.Do(parseConfig)
|
||||||
|
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()
|
keyRing := c.SecretRingFile()
|
||||||
if !fileExists(keyRing) {
|
if !fileExists(keyRing) {
|
||||||
|
|
|
@ -176,8 +176,8 @@ func (w *World) CmdWithEnv(binary string, env []string, args ...string) *exec.Cm
|
||||||
"CAMLI_CONFIG_DIR=" + clientConfigDir,
|
"CAMLI_CONFIG_DIR=" + clientConfigDir,
|
||||||
// Respected by env expansions in config/dev-client-dir/client-config.json:
|
// Respected by env expansions in config/dev-client-dir/client-config.json:
|
||||||
"CAMLI_SERVER=" + w.ServerBaseURL(),
|
"CAMLI_SERVER=" + w.ServerBaseURL(),
|
||||||
"CAMLI_SECRET_RING=" + filepath.Join(w.camRoot, "pkg", "jsonsign", "testdata", "test-secring.gpg"),
|
"CAMLI_SECRET_RING=" + w.SecretRingFile(),
|
||||||
"CAMLI_KEYID=26F5ABDA",
|
"CAMLI_KEYID=" + w.ClientIdentity(),
|
||||||
"CAMLI_AUTH=userpass:testuser:passTestWorld",
|
"CAMLI_AUTH=userpass:testuser:passTestWorld",
|
||||||
}, env...)
|
}, env...)
|
||||||
default:
|
default:
|
||||||
|
@ -240,3 +240,15 @@ func MustRunCmd(t *testing.T, c *exec.Cmd) string {
|
||||||
}
|
}
|
||||||
return out
|
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")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue