Fossil

Check-in [bab84bd7]
Login

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

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rberteig-json-test
Files: files | file ages | folders
SHA1:bab84bd74237641cb7a2597945f575955786884e
User & Date: rberteig 2016-01-28 20:21:25
Context
2016-01-29
02:37
Added more coverage of /json, leaving /json/login, /json/diff, and /json/user/save uncovered, and finding surprises with /json/wiki/diff, /json/timeline/ci, and /json/tag/cancel. All implemented coverage is of the best documented and easiest tested paths through each feature. Tests for edge cases and failure paths are not yet in place, nor are complete tests for full expected values in most cases. check-in: c2c49b35 user: rberteig tags: rberteig-json-test
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/json.test.

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
192
193
194
195
196
197
198






199
200
201
202
203
204
205
...
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
236
# Check for basic envelope fields in a HTTP result with a successful
# command
fossil_http_json /json/HAI
test_json_envelope_ok json-http-HAI
test_json_payload json-http-HAI $HAIfields {}
test json-http-HAI-api {[dict get $JR payload jsonApiVersion] >= 20120713}


fossil_json version
test_json_envelope_ok json-version
test_json_payload json-version $HAIfields {}
test json-version-api {[dict get $JR payload jsonApiVersion] >= 20120713}

#### ARTIFACT

................................................................................
# json artifact (file)
fossil_json [concat artifact $UUID_empty]
test_json_envelope_ok json-artifact-file-env
test json-artifact-file {[dict get $JR payload type] eq "file"}
test_json_payload json-artifact [concat type uuid size checkins] {}

# json artifact (wiki)
fossil wiki create Empty <<""
fossil_json wiki get Empty
test json-wiki-get {[dict get $JR payload name] eq "Empty"}
set uuid [dict get $JR payload uuid]
fossil_json artifact $uuid
test_json_envelope_ok json-artifact-wiki-env
test json-artifact-wiki {[dict get $JR payload type] eq "wiki"}
test_json_payload json-artifact-wiki [list type uuid artifact] {}
................................................................................
  }
}
}]
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":{
................................................................................
  }
}
}
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
#### STATUS







<







 







|







 







>
>
>
>
>
>







 







|
<


|
>
>
>
>
|




|

>
>
|

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

>
>
>
>
>
>







129
130
131
132
133
134
135

136
137
138
139
140
141
142
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
...
213
214
215
216
217
218
219
220

221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# Check for basic envelope fields in a HTTP result with a successful
# command
fossil_http_json /json/HAI
test_json_envelope_ok json-http-HAI
test_json_payload json-http-HAI $HAIfields {}
test json-http-HAI-api {[dict get $JR payload jsonApiVersion] >= 20120713}


fossil_json version
test_json_envelope_ok json-version
test_json_payload json-version $HAIfields {}
test json-version-api {[dict get $JR payload jsonApiVersion] >= 20120713}

#### ARTIFACT

................................................................................
# json artifact (file)
fossil_json [concat artifact $UUID_empty]
test_json_envelope_ok json-artifact-file-env
test json-artifact-file {[dict get $JR payload type] eq "file"}
test_json_payload json-artifact [concat type uuid size checkins] {}

# json artifact (wiki)
fossil wiki create Empty empty
fossil_json wiki get Empty
test json-wiki-get {[dict get $JR payload name] eq "Empty"}
set uuid [dict get $JR payload uuid]
fossil_json artifact $uuid
test_json_envelope_ok json-artifact-wiki-env
test json-artifact-wiki {[dict get $JR payload type] eq "wiki"}
test_json_payload json-artifact-wiki [list type uuid artifact] {}
................................................................................
  }
}
}]
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]
proc test_hascaps {testname need caps} {
  foreach n [split $need {}] {
    test $testname-$n {[string first $n $caps] >= 0}
  }
}
test_hascaps json-login-c "hmnc" [dict get $AuthAnon capabilities]

fossil user new U1 User-1 Uone
fossil user capabilities U1 s
write_file u1 {
{
  "command":"login",
  "payload":{
................................................................................
  }
}
}
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]
test_hascaps json-login-c "s" [dict get $AuthU1 capabilities]


# json cap
# The CLI user has all rights, and no auth token affects that. This
# is consistent with the rest of the fossil CLI, and with the
# pragmatic argument that using the CLI implies physical access to
# the repo file itself, which can be taunted with many tools
# including raw SQLite which will also ignore authentication.
write_file anon-2 [subst {
  {"command":"cap",
   "authToken":"[dict get $AuthAnon]"
  }
}]
fossil_json --json-input anon-2
test_json_envelope_ok json-cap-env
# No point checking any other flags, setup implies all, and all are
# moot from CLI.
test json-cap-CLI {[dict get $JR payload permissionFlags setup]}

test TODO-JSON-POST-AUTHENTICATION false knownBug
#TODO: implement support for POST with JSON payload from file
#fossil_http_post_json /json anon-2
#test_json_envelope_ok json-cap-http-env
#test json-cap-http {![dict get $JR payload permissionFlags setup]}

# whoami
# via CLI with no auth token supplied
fossil_json whoami
test_json_envelope_ok json-whoami-cli-env
test_json_payload json-whoami-cli {name capabilities} {}
test json-whoami-cli-name {[dict get $JR payload name] eq "nobody"}
test_hascaps json-whoami-cli-cap "gjorz" [dict get $JR payload capabilities]

#### BRANCHES
fossil_json branch list
test_json_envelope_ok json-branch-list-env
test_json_payload json-branch-list {range current branches} {}



#### CONFIG
#### DIFFS
#### DIRECTORY LISTING
#### FILE INFO
#### QUERY
#### STATS
#### STATUS