@@ -25,14 +25,19 @@ func TestClient_CreateAuthKey(t *testing.T) {
25
25
capabilities .Devices .Create .Preauthorized = true
26
26
capabilities .Devices .Create .Tags = []string {"test:test" }
27
27
28
+ expiry := 1440 * time .Second
29
+
28
30
expected := & Key {
29
- ID : "test" ,
30
- KeyType : "auth" ,
31
- Key : "thisisatestkey" ,
32
- Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
33
- Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
34
- Capabilities : capabilities ,
35
- Description : "" ,
31
+ ID : "test" ,
32
+ KeyType : "auth" ,
33
+ Key : "thisisatestkey" ,
34
+ ExpirySeconds : & expiry ,
35
+ Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
36
+ Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
37
+ Capabilities : capabilities ,
38
+ Scopes : nil ,
39
+ Tags : nil ,
40
+ Description : "" ,
36
41
}
37
42
38
43
server .ResponseBody = expected
@@ -64,14 +69,19 @@ func TestClient_CreateAuthKeyWithExpirySeconds(t *testing.T) {
64
69
capabilities .Devices .Create .Preauthorized = true
65
70
capabilities .Devices .Create .Tags = []string {"test:test" }
66
71
72
+ expiry := 1440 * time .Second
73
+
67
74
expected := & Key {
68
- ID : "test" ,
69
- KeyType : "auth" ,
70
- Key : "thisisatestkey" ,
71
- Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
72
- Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
73
- Capabilities : capabilities ,
74
- Description : "" ,
75
+ ID : "test" ,
76
+ KeyType : "auth" ,
77
+ Key : "thisisatestkey" ,
78
+ ExpirySeconds : & expiry ,
79
+ Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
80
+ Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
81
+ Capabilities : capabilities ,
82
+ Scopes : nil ,
83
+ Tags : nil ,
84
+ Description : "" ,
75
85
}
76
86
77
87
server .ResponseBody = expected
@@ -105,13 +115,16 @@ func TestClient_CreateAuthKeyWithDescription(t *testing.T) {
105
115
capabilities .Devices .Create .Tags = []string {"test:test" }
106
116
107
117
expected := & Key {
108
- ID : "test" ,
109
- KeyType : "auth" ,
110
- Key : "thisisatestkey" ,
111
- Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
112
- Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
113
- Capabilities : capabilities ,
114
- Description : "key description" ,
118
+ ID : "test" ,
119
+ KeyType : "auth" ,
120
+ Key : "thisisatestkey" ,
121
+ ExpirySeconds : nil ,
122
+ Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
123
+ Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
124
+ Capabilities : capabilities ,
125
+ Scopes : nil ,
126
+ Tags : nil ,
127
+ Description : "key description" ,
115
128
}
116
129
117
130
server .ResponseBody = expected
@@ -139,12 +152,15 @@ func TestClient_CreateOAuthClient(t *testing.T) {
139
152
server .ResponseCode = http .StatusOK
140
153
141
154
expected := & Key {
142
- ID : "test" ,
143
- KeyType : "client" ,
144
- Key : "thisisatestclient" ,
145
- Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
146
- Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
147
- Description : "" ,
155
+ ID : "test" ,
156
+ KeyType : "client" ,
157
+ Key : "thisisatestclient" ,
158
+ ExpirySeconds : nil ,
159
+ Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
160
+ Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
161
+ Scopes : []string {"all:read" },
162
+ Tags : []string {"tag:test" },
163
+ Description : "" ,
148
164
}
149
165
150
166
server .ResponseBody = expected
@@ -181,12 +197,15 @@ func TestClient_GetKey(t *testing.T) {
181
197
capabilities .Devices .Create .Tags = []string {"test:test" }
182
198
183
199
expected := & Key {
184
- ID : "test" ,
185
- KeyType : "auth" ,
186
- Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
187
- Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
188
- Capabilities : capabilities ,
189
- Description : "" ,
200
+ ID : "test" ,
201
+ KeyType : "auth" ,
202
+ ExpirySeconds : nil ,
203
+ Created : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
204
+ Expires : time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
205
+ Capabilities : capabilities ,
206
+ Scopes : nil ,
207
+ Tags : nil ,
208
+ Description : "" ,
190
209
}
191
210
192
211
server .ResponseBody = expected
0 commit comments