-
Notifications
You must be signed in to change notification settings - Fork 7
/
paths_issue_test.go
162 lines (148 loc) · 4.75 KB
/
paths_issue_test.go
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package natsbackend
// func TestNatsWithAccountServer(t *testing.T) {
// /////////////////////////////////////////////////////
// // Create all necessary secrets to start nats server
// /////////////////////////////////////////////////////
// //------------------------
// // Prepare
// //------------------------
// var request map[string]interface{}
// b, reqStorage := getTestBackend(t)
// var currentOperator IssueOperatorData
// var expectedOperator IssueOperatorData
// var currentAccount IssueAccountData
// var expectedAccount IssueAccountData
// //------------------------
// // That will be requested
// //------------------------
// onIssue := "issue/operator/operator"
// mstm.StructToMap(&IssueOperatorParameters{
// CreateSystemAccount: true,
// AccountServerURL: "nats://localhost:4222",
// SyncAccountServer: true,
// }, &request)
// //------------------------
// // That will be expected
// //------------------------
// expectedOperator = IssueOperatorData{
// Operator: "operator",
// SigningKeys: []string(nil),
// CreateSystemAccount: true,
// AccountServerURL: "nats://localhost:4222",
// SyncAccountServer: true,
// Claims: operatorv1.OperatorClaims{},
// Status: IssueOperatorStatus{
// Operator: IssueStatus{
// Nkey: true,
// JWT: true,
// },
// SystemAccount: IssueStatus{
// Nkey: true,
// JWT: true,
// },
// SystemAccountUser: IssueStatus{
// Nkey: true,
// JWT: true,
// },
// },
// }
// //------------------------
// // create issue
// //------------------------
// resp, err := b.HandleRequest(context.Background(), &logical.Request{
// Operation: logical.CreateOperation,
// Path: onIssue,
// Storage: reqStorage,
// Data: request,
// })
// assert.NoError(t, err)
// assert.False(t, resp.IsError())
// //////////////////////////
// // read the created issue
// //////////////////////////
// resp, err = b.HandleRequest(context.Background(), &logical.Request{
// Operation: logical.ReadOperation,
// Path: onIssue,
// Storage: reqStorage,
// })
// assert.NoError(t, err)
// assert.False(t, resp.IsError())
// //////////////////////////////////
// // Compare the expected and current
// //////////////////////////////////
// stm.MapToStruct(resp.Data, ¤tOperator)
// assert.Equal(t, expectedOperator, currentOperator)
// /////////////////////////////
// // read system account issue
// // created by the operator
// /////////////////////////////
// resp, err = b.HandleRequest(context.Background(), &logical.Request{
// Operation: logical.ReadOperation,
// Path: onIssue + "/account/" + DefaultSysAccountName,
// Storage: reqStorage,
// })
// assert.NoError(t, err)
// assert.False(t, resp.IsError())
// //------------------------
// // That will be expected
// //------------------------
// expectedAccount = IssueAccountData{
// Operator: "operator",
// Account: DefaultSysAccountName,
// UseSigningKey: "",
// SigningKeys: []string(nil),
// Claims: accountv1.AccountClaims{
// Account: accountv1.Account{
// Exports: []accountv1.Export{
// {
// Name: "account-monitoring-services",
// Subject: "$SYS.REQ.ACCOUNT.*.*",
// Type: "Service",
// ResponseType: jwt.ResponseTypeStream,
// AccountTokenPosition: 4,
// Info: common.Info{
// Description: `Request account specific monitoring services for: SUBSZ, CONNZ, LEAFZ, JSZ and INFO`,
// InfoURL: "https://docs.nats.io/nats-server/configuration/sys_accounts",
// },
// },
// {
// Name: "account-monitoring-streams",
// Subject: "$SYS.ACCOUNT.*.>",
// Type: "Stream",
// AccountTokenPosition: 3,
// Info: common.Info{
// Description: `Account specific monitoring stream`,
// InfoURL: "https://docs.nats.io/nats-server/configuration/sys_accounts",
// },
// },
// },
// Limits: accountv1.OperatorLimits{
// NatsLimits: common.NatsLimits{
// Subs: -1,
// Data: -1,
// Payload: -1,
// },
// AccountLimits: accountv1.AccountLimits{
// Imports: -1,
// Exports: -1,
// WildcardExports: true,
// Conn: -1,
// LeafNodeConn: -1,
// },
// },
// },
// },
// Status: IssueAccountStatus{
// Account: IssueStatus{
// Nkey: true,
// JWT: true,
// },
// AccountServer: AccountServerStatus{
// Synced: false,
// LastSync: 0,
// },
// },
// }
// stm.MapToStruct(resp.Data, ¤tAccount)
// assert.Equal(t, expectedAccount, currentAccount)
// }