1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package policytest
import (
"time"
"github.com/johnandersen777/socialweb-computer-kcp/internal/policyengine/trust"
)
type Parties struct {
Self, SelfOp, SelfSvc string
CP, CPOp, CPSvc string
}
func PartiesFor(perspective string) Parties {
if perspective == "requester" {
return Parties{Self: Requester, SelfOp: ReqOperator, SelfSvc: trust.RequesterAssociate,
CP: Bidder, CPOp: BidderOperator, CPSvc: trust.BidderAssociate}
}
return Parties{Self: Bidder, SelfOp: BidderOperator, SelfSvc: trust.BidderAssociate,
CP: Requester, CPOp: ReqOperator, CPSvc: trust.RequesterAssociate}
}
type TrustCase struct {
Name string
Build func(w *World, p Parties)
Vouch bool
OnlyMe bool
Mutuals bool
}
var TrustCases = []TrustCase{
{Name: "unvouched", Build: func(w *World, p Parties) {}},
{Name: "vouched-by-self", Vouch: true, Build: func(w *World, p Parties) {
w.Vouch(p.Self, p.CP)
}},
{Name: "vouched-by-verified-self-operator", Vouch: true, Build: func(w *World, p Parties) {
w.Associate(p.Self, p.SelfOp, p.SelfSvc)
w.Vouch(p.SelfOp, p.CP)
}},
{Name: "vouched-by-self-claimed-self-operator", Build: func(w *World, p Parties) {
w.Mirror(p.Self, p.SelfOp, p.SelfSvc)
w.Vouch(p.SelfOp, p.CP)
}},
{Name: "verified-counterparty-operator-vouched-by-self", Vouch: true, Build: func(w *World, p Parties) {
w.Associate(p.CP, p.CPOp, p.CPSvc)
w.Vouch(p.Self, p.CPOp)
}},
{Name: "verified-counterparty-operator-vouched-by-self-operator", Vouch: true, Build: func(w *World, p Parties) {
w.Associate(p.Self, p.SelfOp, p.SelfSvc)
w.Associate(p.CP, p.CPOp, p.CPSvc)
w.Vouch(p.SelfOp, p.CPOp)
}},
{Name: "forged-counterparty-operator-claim", Build: func(w *World, p Parties) {
w.Vouch(p.Self, p.CPOp)
w.Mirror(p.CP, p.CPOp, p.CPSvc)
}},
{Name: "claim-for-the-other-role", Build: func(w *World, p Parties) {
w.Vouch(p.Self, p.CPOp)
w.Associate(p.CP, p.CPOp, p.SelfSvc)
}},
{Name: "vouched-directly-with-verified-operator", Vouch: true, Build: func(w *World, p Parties) {
w.Associate(p.CP, p.CPOp, p.CPSvc)
w.Vouch(p.Self, p.CP)
}},
{Name: "counterparty-operator-vouches-self-only", Build: func(w *World, p Parties) {
w.Associate(p.CP, p.CPOp, p.CPSvc)
w.Vouch(p.CPOp, p.Self)
}},
{Name: "mutual-operator-vouches", Vouch: true, Mutuals: true, Build: func(w *World, p Parties) {
w.Associate(p.CP, p.CPOp, p.CPSvc)
w.Vouch(p.Self, p.CPOp)
w.Vouch(p.CPOp, p.Self)
}},
{Name: "denounced", Build: func(w *World, p Parties) {
w.Denounce(p.Self, p.CP)
}},
{Name: "stranger-vouches", Build: func(w *World, p Parties) {
w.Vouch(Stranger, p.CP)
w.Vouch(p.CP, p.Self)
}},
{Name: "same-verified-operator", OnlyMe: true, Vouch: true, Mutuals: true, Build: func(w *World, p Parties) {
w.Associate(p.Self, p.SelfOp, p.SelfSvc)
w.Associate(p.CP, p.SelfOp, p.CPSvc)
}},
{Name: "counterparty-operated-by-self", OnlyMe: true, Vouch: true, Mutuals: true, Build: func(w *World, p Parties) {
w.Associate(p.CP, p.Self, p.CPSvc)
}},
{Name: "forged-same-operator", Build: func(w *World, p Parties) {
w.Associate(p.Self, p.SelfOp, p.SelfSvc)
w.Mirror(p.CP, p.SelfOp, p.CPSvc)
}},
{Name: "different-verified-operators", Build: func(w *World, p Parties) {
w.Associate(p.Self, p.SelfOp, p.SelfSvc)
w.Associate(p.CP, p.CPOp, p.CPSvc)
}},
{Name: "contract-scoped-association-held", OnlyMe: true, Vouch: true, Mutuals: true, Build: func(w *World, p Parties) {
w.Associate(p.Self, p.SelfOp, p.SelfSvc)
contract := w.HeldContract(p.SelfOp, OtherBidder)
w.ContractAssociation(p.CP, p.SelfOp, p.CPSvc, contract, time.Now().Add(time.Hour))
}},
{Name: "contract-scoped-association-expired", Build: func(w *World, p Parties) {
w.Associate(p.Self, p.SelfOp, p.SelfSvc)
contract := w.HeldContract(p.SelfOp, OtherBidder)
w.ContractAssociation(p.CP, p.SelfOp, p.CPSvc, contract, time.Now().Add(-time.Minute))
}},
{Name: "contract-scoped-association-released", Build: func(w *World, p Parties) {
w.Associate(p.Self, p.SelfOp, p.SelfSvc)
contract := w.HeldContract(p.SelfOp, OtherBidder)
w.ContractAssociation(p.CP, p.SelfOp, p.CPSvc, contract, time.Now().Add(time.Hour))
w.Release(p.SelfOp, contract)
}},
{Name: "contract-scoped-association-terminated", Build: func(w *World, p Parties) {
w.Associate(p.Self, p.SelfOp, p.SelfSvc)
contract := w.HeldContract(p.SelfOp, OtherBidder)
w.ContractAssociation(p.CP, p.SelfOp, p.CPSvc, contract, time.Now().Add(time.Hour))
w.Terminate(contract)
}},
}