Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Also test /json/wiki/preview, /json/g, /json/rebuild, /json/resultCodes, /json/anonymousPassword, /json/login for both anonymous and a normal user. Note that test for /json/cap is a work in progress since the CLI ingores any auth tokens and always acts with all caps.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rberteig-json-test
Files: files | file ages | folders
SHA1:9b8b051899ca59b49b8fa51992d108356888208b
User & Date: rberteig 2016-01-28 02:53:45
Context
2016-01-28
20:21
Added /json/whoami from CLI, changed /json/cap to only care that it worked from CLI since capabilities are sort of meaningless in CLI mode. Added checks for caps provided to each logged in user by /json/login from its own results. Starting on /json/branch/list. All tests pass except known bugs and TODOs. check-in: bab84bd7 user: rberteig tags: rberteig-json-test
02:53
Also test /json/wiki/preview, /json/g, /json/rebuild, /json/resultCodes, /json/anonymousPassword, /json/login for both anonymous and a normal user. Note that test for /json/cap is a work in progress since the CLI ingores any auth tokens and always acts with all caps. check-in: 9b8b0518 user: rberteig tags: rberteig-json-test
01:19
Refactoring in the json tests. Add coverage of /json/wiki. Note discrepency between documentation and execution of /json/wiki/diff. check-in: cb611ffc user: rberteig tags: rberteig-json-test
Changes

Changes to test/json.test.

172
173
174
175
176
177
178


















































179
180
181
182
183
184
185
...
252
253
254
255
256
257
258
259
260
261

















262
263





264














set artifact [dict get $JR payload artifact]
test_dict_keys json-artifact-wiki-artifact $artifact \
  [list name uuid user timestamp size] {}
# name, uuid, parent?, user, timestamp, size?, content?


#### AUTHENTICATION


















































#### BRANCHES
#### CONFIG
#### DIFFS
#### DIRECTORY LISTING
#### FILE INFO
#### QUERY
#### STATS
................................................................................

fossil_json wiki diff $uuid1 $uuid2
test_json_envelope_ok json-wiki-diff-env
test_json_payload json-wiki-diff [list v1 v2 diff] {}
test json-wiki-diff-v1 {[dict get $JR payload v1] eq $uuid1}
test json-wiki-diff-v1 {[dict get $JR payload v2] eq $uuid2}
set diff [dict get $JR payload diff]
test json-wiki-diff-diff {[string first "+consectetur adipisicing elit" $diff] >= 0} ;#knownBug
#puts [dict get $JR payload diff]


















#### UNAVOIDABLE MISC




























>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
...
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
set artifact [dict get $JR payload artifact]
test_dict_keys json-artifact-wiki-artifact $artifact \
  [list name uuid user timestamp size] {}
# name, uuid, parent?, user, timestamp, size?, content?


#### AUTHENTICATION
fossil_json anonymousPassword
test_json_envelope_ok json-anonymousPassword-env
test_json_payload json-anonymousPassword {seed password} {}
set seed [dict get $JR payload seed]
set pass [dict get $JR payload password]

write_file anon-1 [subst {
{
  "command":"login",
  "payload":{
    "name":"anonymous",
    "anonymousSeed":$seed,
    "password":"$pass"
  }
}
}]
fossil_json --json-input anon-1
test_json_envelope_ok json-login-a-env
test_json_payload json-login-a {authToken name capabilities loginCookieName} {}
set AuthAnon [dict get $JR payload]

fossil user new U1 User-1 Uone
fossil user capabilities U1 s
write_file u1 {
{
  "command":"login",
  "payload":{
    "name":"U1",
    "password":"Uone"
  }
}
}
fossil_json --json-input u1
test_json_envelope_ok json-login-u1-env
test_json_payload json-login-u1 {authToken name capabilities loginCookieName} {}
set AuthU1 [dict get $JR payload]
#puts $AuthAnon
#puts $AuthU1

# json cap
# Bug? The CLI user has all rights, and no auth token affects that.
write_file u2 [subst {
  {"command":"cap",
   "authToken":"[dict get $AuthAnon]"
  }
}]
fossil_json --json-input u2
test_json_envelope_ok json-cap-env
#puts [dict get $JR payload]

#### BRANCHES
#### CONFIG
#### DIFFS
#### DIRECTORY LISTING
#### FILE INFO
#### QUERY
#### STATS
................................................................................

fossil_json wiki diff $uuid1 $uuid2
test_json_envelope_ok json-wiki-diff-env
test_json_payload json-wiki-diff [list v1 v2 diff] {}
test json-wiki-diff-v1 {[dict get $JR payload v1] eq $uuid1}
test json-wiki-diff-v1 {[dict get $JR payload v2] eq $uuid2}
set diff [dict get $JR payload diff]
test json-wiki-diff-diff {[string first "+consectetur adipisicing elit" $diff] >= 0} knownBug
#puts [dict get $JR payload diff]

# wiki preview
#
# takes a string in fossil wiki markup and return an HTML fragment.
# This command does not make use of the actual wiki content (much?)
# at all.
write_file req3.json {
  {
    "command":"wiki/preview",
    "payload":"Lorem ipsum dolor sic amet.\nconsectetur adipisicing elit."
  }
}
fossil_json --json-input req3.json
test_json_envelope_ok json-wiki-preview-env
set pv [dict get $JR payload]
test json-wiki-preview-out-1 {[string first "<p>Lorem ipsum" $pv] == 0}
test json-wiki-preview-out-2 {[string last "<p>" $pv] == 0}

#### UNAVOIDABLE MISC

# json g
fossil_json g
test_json_envelope_ok json-g-env
#puts [llength [dict keys [dict get $JR payload]]]
test json-g-g {[llength [dict keys [dict get $JR payload]]] >= 60};# 64 on my PC

# json rebuild
fossil_json rebuild
test_json_envelope json-rebuild-env [concat fossil timestamp command procTimeUs \
  procTimeMs] [concat payload resultCode resultText]

# json resultCodes
fossil_json resultCodes
test_json_envelope_ok json-resultCodes-env
set codes [dict get $JR payload]
test json-resultCodes-codes-1 {[llength $codes] >= 35} ;# count as of API 20120713
# foreach c $codes {
#   puts [dict values $c]
# }