mirror of https://github.com/perkeep/perkeep.git
Merge "devcam test: generate keyblob with devcam put init"
This commit is contained in:
commit
db63bcc6d0
|
@ -14,10 +14,6 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// TODO(mpl): Shouldn't we move this subcommand to camtool? e.g as 'camtool configinit' ?
|
||||
// It does not feel like a good fit in camput since this does not send anything
|
||||
// to a server.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -40,6 +36,7 @@ import (
|
|||
type initCmd struct {
|
||||
newKey bool
|
||||
gpgkey string
|
||||
noconfig bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -47,6 +44,7 @@ func init() {
|
|||
cmd := new(initCmd)
|
||||
flags.BoolVar(&cmd.newKey, "newkey", false, "Automatically generate a new identity in a new secret ring.")
|
||||
flags.StringVar(&cmd.gpgkey, "gpgkey", "", "GPG key to use for signing (overrides $GPGKEY environment)")
|
||||
flags.BoolVar(&cmd.noconfig, "noconfig", false, "Stop after creating the public key blob, and do not try and create a config file.")
|
||||
return cmd
|
||||
})
|
||||
}
|
||||
|
@ -172,6 +170,10 @@ func (c *initCmd) RunCommand(args []string) error {
|
|||
|
||||
log.Printf("Your Camlistore identity (your GPG public key's blobref) is: %s", bref.String())
|
||||
|
||||
if c.noconfig {
|
||||
return nil
|
||||
}
|
||||
|
||||
configFilePath := osutil.UserClientConfigPath()
|
||||
_, err = os.Stat(configFilePath)
|
||||
if err == nil {
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
"handler": "jsonsign",
|
||||
"handlerArgs": {
|
||||
"secretRing": ["_env", "${CAMLI_SECRET_RING}"],
|
||||
"keyId": "26F5ABDA",
|
||||
"keyId": ["_env", "${CAMLI_KEYID}"],
|
||||
"publicKeyDest": "/bs/"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -131,8 +131,8 @@ func (c *getCmd) build() error {
|
|||
|
||||
func (c *getCmd) setEnvVars() error {
|
||||
setenv("CAMLI_CONFIG_DIR", filepath.Join("config", "dev-client-dir"))
|
||||
setenv("CAMLI_SECRET_RING", filepath.FromSlash("pkg/jsonsign/testdata/test-secring.gpg"))
|
||||
setenv("CAMLI_KEYID", "26F5ABDA")
|
||||
setenv("CAMLI_SECRET_RING", filepath.FromSlash(defaultSecring))
|
||||
setenv("CAMLI_KEYID", defaultKeyID)
|
||||
setenv("CAMLI_AUTH", "userpass:camlistore:pass3179")
|
||||
setenv("CAMLI_DEV_KEYBLOBS", filepath.FromSlash("config/dev-client-dir/keyblobs"))
|
||||
c.verbose, _ = strconv.ParseBool(os.Getenv("CAMLI_QUIET"))
|
||||
|
|
|
@ -132,8 +132,8 @@ func (c *putCmd) build() error {
|
|||
|
||||
func (c *putCmd) setEnvVars() error {
|
||||
setenv("CAMLI_CONFIG_DIR", filepath.Join("config", "dev-client-dir"))
|
||||
setenv("CAMLI_SECRET_RING", filepath.FromSlash("pkg/jsonsign/testdata/test-secring.gpg"))
|
||||
setenv("CAMLI_KEYID", "26F5ABDA")
|
||||
setenv("CAMLI_SECRET_RING", filepath.FromSlash(defaultSecring))
|
||||
setenv("CAMLI_KEYID", defaultKeyID)
|
||||
setenv("CAMLI_AUTH", "userpass:camlistore:pass3179")
|
||||
setenv("CAMLI_DEV_KEYBLOBS", filepath.FromSlash("config/dev-client-dir/keyblobs"))
|
||||
if c.altkey {
|
||||
|
|
|
@ -33,6 +33,13 @@ import (
|
|||
"camlistore.org/pkg/osutil"
|
||||
)
|
||||
|
||||
const (
|
||||
// default secret ring used in tests and in devcam commands
|
||||
defaultSecring = "pkg/jsonsign/testdata/test-secring.gpg"
|
||||
// public ID of the GPG key in defaultSecring
|
||||
defaultKeyID = "26F5ABDA"
|
||||
)
|
||||
|
||||
type serverCmd struct {
|
||||
// start of flag vars
|
||||
all bool
|
||||
|
@ -273,7 +280,8 @@ func (c *serverCmd) setEnvVars() error {
|
|||
}
|
||||
setenv("CAMLI_PORT", c.port)
|
||||
setenv("CAMLI_SECRET_RING", filepath.Join(camliSrcRoot,
|
||||
filepath.FromSlash("pkg/jsonsign/testdata/test-secring.gpg")))
|
||||
filepath.FromSlash(defaultSecring)))
|
||||
setenv("CAMLI_KEYID", defaultKeyID)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,9 @@ func (c *testCmd) RunCommand(args []string) error {
|
|||
if err := c.buildSelf(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.genKeyBlob(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.runTests(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -86,27 +89,6 @@ func (c *testCmd) syncSrc() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *testCmd) runTests() error {
|
||||
args := []string{"test"}
|
||||
if !strings.HasSuffix(c.buildGoPath, "-nosqlite") {
|
||||
args = append(args, "--tags=with_sqlite")
|
||||
}
|
||||
if c.short {
|
||||
args = append(args, "-short")
|
||||
}
|
||||
args = append(args, []string{
|
||||
"./pkg/...",
|
||||
"./server/camlistored",
|
||||
"./server/appengine",
|
||||
"./cmd/...",
|
||||
}...)
|
||||
env := append(cleanGoEnv(),
|
||||
"SKIP_DEP_TESTS=1",
|
||||
"GOPATH="+c.buildGoPath,
|
||||
)
|
||||
return runExec("go", args, env)
|
||||
}
|
||||
|
||||
// cleanGoEnv returns a copy of the current environment with GOPATH and
|
||||
// GOBIN removed.
|
||||
func cleanGoEnv() (clean []string) {
|
||||
|
@ -143,3 +125,45 @@ func (c *testCmd) buildSelf() error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *testCmd) genKeyBlob() error {
|
||||
cmdBin := filepath.FromSlash("./bin/devcam")
|
||||
args := []string{
|
||||
"put",
|
||||
"init",
|
||||
"--gpgkey="+defaultKeyID,
|
||||
"--noconfig",
|
||||
}
|
||||
cmd := exec.Command(cmdBin, args...)
|
||||
cmd.Env = append(cleanGoEnv(),
|
||||
"CAMLI_SECRET_RING="+filepath.FromSlash(defaultSecring),
|
||||
"GOPATH="+c.buildGoPath,
|
||||
)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("Error generating keyblobs: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *testCmd) runTests() error {
|
||||
args := []string{"test"}
|
||||
if !strings.HasSuffix(c.buildGoPath, "-nosqlite") {
|
||||
args = append(args, "--tags=with_sqlite")
|
||||
}
|
||||
if c.short {
|
||||
args = append(args, "-short")
|
||||
}
|
||||
args = append(args, []string{
|
||||
"./pkg/...",
|
||||
"./server/camlistored",
|
||||
"./server/appengine",
|
||||
"./cmd/...",
|
||||
}...)
|
||||
env := append(cleanGoEnv(),
|
||||
"SKIP_DEP_TESTS=1",
|
||||
"GOPATH="+c.buildGoPath,
|
||||
)
|
||||
return runExec("go", args, env)
|
||||
}
|
||||
|
|
|
@ -78,6 +78,11 @@ CAMLI_INCLUDE_PATH (string):
|
|||
directory. It should be in the OS path form, i.e. unix-like systems would be
|
||||
/path/1:/path/two:/some/other/path, and Windows would be C:\path\one;D:\path\2
|
||||
|
||||
CAMLI_KEYID (string):
|
||||
devcam commands only, used by config/dev-server-config.json, and
|
||||
config/dev-client-dir/client-config.json: public ID of the GPG key
|
||||
to use for signing.
|
||||
|
||||
CAMLI_MONGO_WIPE (bool):
|
||||
Wipe out mongo based index on startup.
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ var NameToCmd = map[string]string{
|
|||
"buildGoTip1": "./make.bash",
|
||||
"buildCamli1": "go run make.go -v",
|
||||
"buildCamli2": "go build -o devcam ./dev/devcam/",
|
||||
"buildCamli3": "devcam test",
|
||||
"buildCamli3": "./devcam test",
|
||||
"runCamli": "./devcam server --wipe --mysql",
|
||||
"hitCamliUi1": "http://localhost:3179/ui/",
|
||||
"camget": "./devcam get ",
|
||||
|
|
Loading…
Reference in New Issue