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.
51 lines
1.3 KiB
51 lines
1.3 KiB
![]()
3 years ago
|
package dehub
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"gopkg.in/src-d/go-git.v4/plumbing"
|
||
|
)
|
||
|
|
||
![]()
3 years ago
|
func TestPayloadCredentialVerify(t *testing.T) {
|
||
![]()
3 years ago
|
h := newHarness(t)
|
||
![]()
3 years ago
|
rootSig := h.stageNewAccount("root", false)
|
||
![]()
3 years ago
|
|
||
|
// create a new account and modify the config so that that account is only
|
||
|
// allowed to add verifications to a single branch
|
||
![]()
3 years ago
|
tootSig := h.stageNewAccount("toot", false)
|
||
![]()
3 years ago
|
tootBranch := plumbing.NewBranchReferenceName("toot_branch")
|
||
![]()
3 years ago
|
h.stageAccessControls(`
|
||
![]()
3 years ago
|
- action: allow
|
||
|
filters:
|
||
|
- type: branch
|
||
![]()
3 years ago
|
pattern: ` + tootBranch.Short() + `
|
||
![]()
3 years ago
|
- type: signature
|
||
|
count: 1
|
||
|
account_ids:
|
||
|
- root
|
||
|
- toot
|
||
|
|
||
|
- action: allow
|
||
|
filters:
|
||
|
- type: signature
|
||
|
count: 1
|
||
|
account_ids:
|
||
|
- root
|
||
![]()
3 years ago
|
`)
|
||
![]()
3 years ago
|
rootGitCommit := h.assertCommitChange(verifyShouldSucceed, "initial commit", rootSig)
|
||
![]()
3 years ago
|
|
||
|
// toot user wants to create a credential commit for the root commit, for
|
||
|
// whatever reason.
|
||
![]()
3 years ago
|
rootChangeFingerprint := rootGitCommit.Payload.Common.Fingerprint
|
||
|
credCommitPayUn, err := h.proj.NewPayloadCredential(rootChangeFingerprint)
|
||
![]()
3 years ago
|
if err != nil {
|
||
![]()
3 years ago
|
t.Fatalf("creating credential commit for fingerprint %x: %v", rootChangeFingerprint, err)
|
||
![]()
3 years ago
|
|
||
|
}
|
||
![]()
3 years ago
|
h.tryCommit(verifyShouldFail, credCommitPayUn, tootSig)
|
||
![]()
3 years ago
|
|
||
|
// toot tries again in their own branch, and should be allowed.
|
||
|
h.checkout(tootBranch)
|
||
![]()
3 years ago
|
h.tryCommit(verifyShouldSucceed, credCommitPayUn, tootSig)
|
||
![]()
3 years ago
|
}
|