A read-only clone of the dehub project, for until dehub.dev can be brought back online.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
dehub/commit_test.go

48 lines
1.4 KiB

package dehub
import (
"dehub.dev/src/dehub.git/sigcred"
"testing"
)
func TestConfigChange(t *testing.T) {
h := newHarness(t)
var gitCommits []GitCommit
// commit the initial staged changes, which merely include the config and
// public key
gitCommit := h.changeCommit("commit configuration", h.cfg.Accounts[0].ID, h.sig)
gitCommits = append(gitCommits, gitCommit)
// create a new account and add it to the configuration. That commit should
// not be verifiable, though
newSig, newPubKeyBody := sigcred.SignifierPGPTmp("toot", h.rand)
h.cfg.Accounts = append(h.cfg.Accounts, Account{
ID: "toot",
Signifiers: []sigcred.Signifier{{PGPPublicKey: &sigcred.SignifierPGP{
Body: string(newPubKeyBody),
}}},
})
h.stageCfg()
badCommit, err := h.repo.NewCommitChange("add toot user")
if err != nil {
t.Fatalf("creating CommitChange: %v", err)
}
h.tryCommit(false, badCommit, h.cfg.Accounts[1].ID, newSig)
// now add with the root user, this should work.
h.stageCfg()
gitCommit = h.changeCommit("add toot user", h.cfg.Accounts[0].ID, h.sig)
gitCommits = append(gitCommits, gitCommit)
// _now_ the toot user should be able to do things.
h.stage(map[string]string{"foo/bar": "what a cool file"})
gitCommit = h.changeCommit("add a cool file", h.cfg.Accounts[1].ID, newSig)
gitCommits = append(gitCommits, gitCommit)
if err := h.repo.VerifyCommits(MainRefName, gitCommits); err != nil {
t.Fatal(err)
}
}