Fossil SCM
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.
Commit
9b8b051899ca59b49b8fa51992d108356888208b
Parent
cb611ffc9b2f107…
1 file changed
+87
-1
+87
-1
| --- test/json.test | ||
| +++ test/json.test | ||
| @@ -174,10 +174,60 @@ | ||
| 174 | 174 | [list name uuid user timestamp size] {} |
| 175 | 175 | # name, uuid, parent?, user, timestamp, size?, content? |
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | #### AUTHENTICATION |
| 179 | +fossil_json anonymousPassword | |
| 180 | +test_json_envelope_ok json-anonymousPassword-env | |
| 181 | +test_json_payload json-anonymousPassword {seed password} {} | |
| 182 | +set seed [dict get $JR payload seed] | |
| 183 | +set pass [dict get $JR payload password] | |
| 184 | + | |
| 185 | +write_file anon-1 [subst { | |
| 186 | +{ | |
| 187 | + "command":"login", | |
| 188 | + "payload":{ | |
| 189 | + "name":"anonymous", | |
| 190 | + "anonymousSeed":$seed, | |
| 191 | + "password":"$pass" | |
| 192 | + } | |
| 193 | +} | |
| 194 | +}] | |
| 195 | +fossil_json --json-input anon-1 | |
| 196 | +test_json_envelope_ok json-login-a-env | |
| 197 | +test_json_payload json-login-a {authToken name capabilities loginCookieName} {} | |
| 198 | +set AuthAnon [dict get $JR payload] | |
| 199 | + | |
| 200 | +fossil user new U1 User-1 Uone | |
| 201 | +fossil user capabilities U1 s | |
| 202 | +write_file u1 { | |
| 203 | +{ | |
| 204 | + "command":"login", | |
| 205 | + "payload":{ | |
| 206 | + "name":"U1", | |
| 207 | + "password":"Uone" | |
| 208 | + } | |
| 209 | +} | |
| 210 | +} | |
| 211 | +fossil_json --json-input u1 | |
| 212 | +test_json_envelope_ok json-login-u1-env | |
| 213 | +test_json_payload json-login-u1 {authToken name capabilities loginCookieName} {} | |
| 214 | +set AuthU1 [dict get $JR payload] | |
| 215 | +#puts $AuthAnon | |
| 216 | +#puts $AuthU1 | |
| 217 | + | |
| 218 | +# json cap | |
| 219 | +# Bug? The CLI user has all rights, and no auth token affects that. | |
| 220 | +write_file u2 [subst { | |
| 221 | + {"command":"cap", | |
| 222 | + "authToken":"[dict get $AuthAnon]" | |
| 223 | + } | |
| 224 | +}] | |
| 225 | +fossil_json --json-input u2 | |
| 226 | +test_json_envelope_ok json-cap-env | |
| 227 | +#puts [dict get $JR payload] | |
| 228 | + | |
| 179 | 229 | #### BRANCHES |
| 180 | 230 | #### CONFIG |
| 181 | 231 | #### DIFFS |
| 182 | 232 | #### DIRECTORY LISTING |
| 183 | 233 | #### FILE INFO |
| @@ -254,11 +304,47 @@ | ||
| 254 | 304 | test_json_envelope_ok json-wiki-diff-env |
| 255 | 305 | test_json_payload json-wiki-diff [list v1 v2 diff] {} |
| 256 | 306 | test json-wiki-diff-v1 {[dict get $JR payload v1] eq $uuid1} |
| 257 | 307 | test json-wiki-diff-v1 {[dict get $JR payload v2] eq $uuid2} |
| 258 | 308 | set diff [dict get $JR payload diff] |
| 259 | -test json-wiki-diff-diff {[string first "+consectetur adipisicing elit" $diff] >= 0} ;#knownBug | |
| 309 | +test json-wiki-diff-diff {[string first "+consectetur adipisicing elit" $diff] >= 0} knownBug | |
| 260 | 310 | #puts [dict get $JR payload diff] |
| 261 | 311 | |
| 312 | +# wiki preview | |
| 313 | +# | |
| 314 | +# takes a string in fossil wiki markup and return an HTML fragment. | |
| 315 | +# This command does not make use of the actual wiki content (much?) | |
| 316 | +# at all. | |
| 317 | +write_file req3.json { | |
| 318 | + { | |
| 319 | + "command":"wiki/preview", | |
| 320 | + "payload":"Lorem ipsum dolor sic amet.\nconsectetur adipisicing elit." | |
| 321 | + } | |
| 322 | +} | |
| 323 | +fossil_json --json-input req3.json | |
| 324 | +test_json_envelope_ok json-wiki-preview-env | |
| 325 | +set pv [dict get $JR payload] | |
| 326 | +test json-wiki-preview-out-1 {[string first "<p>Lorem ipsum" $pv] == 0} | |
| 327 | +test json-wiki-preview-out-2 {[string last "<p>" $pv] == 0} | |
| 328 | + | |
| 262 | 329 | #### UNAVOIDABLE MISC |
| 263 | 330 | |
| 331 | +# json g | |
| 332 | +fossil_json g | |
| 333 | +test_json_envelope_ok json-g-env | |
| 334 | +#puts [llength [dict keys [dict get $JR payload]]] | |
| 335 | +test json-g-g {[llength [dict keys [dict get $JR payload]]] >= 60};# 64 on my PC | |
| 336 | + | |
| 337 | +# json rebuild | |
| 338 | +fossil_json rebuild | |
| 339 | +test_json_envelope json-rebuild-env [concat fossil timestamp command procTimeUs \ | |
| 340 | + procTimeMs] [concat payload resultCode resultText] | |
| 341 | + | |
| 342 | +# json resultCodes | |
| 343 | +fossil_json resultCodes | |
| 344 | +test_json_envelope_ok json-resultCodes-env | |
| 345 | +set codes [dict get $JR payload] | |
| 346 | +test json-resultCodes-codes-1 {[llength $codes] >= 35} ;# count as of API 20120713 | |
| 347 | +# foreach c $codes { | |
| 348 | +# puts [dict values $c] | |
| 349 | +# } | |
| 264 | 350 | |
| 265 | 351 |
| --- test/json.test | |
| +++ test/json.test | |
| @@ -174,10 +174,60 @@ | |
| 174 | [list name uuid user timestamp size] {} |
| 175 | # name, uuid, parent?, user, timestamp, size?, content? |
| 176 | |
| 177 | |
| 178 | #### AUTHENTICATION |
| 179 | #### BRANCHES |
| 180 | #### CONFIG |
| 181 | #### DIFFS |
| 182 | #### DIRECTORY LISTING |
| 183 | #### FILE INFO |
| @@ -254,11 +304,47 @@ | |
| 254 | test_json_envelope_ok json-wiki-diff-env |
| 255 | test_json_payload json-wiki-diff [list v1 v2 diff] {} |
| 256 | test json-wiki-diff-v1 {[dict get $JR payload v1] eq $uuid1} |
| 257 | test json-wiki-diff-v1 {[dict get $JR payload v2] eq $uuid2} |
| 258 | set diff [dict get $JR payload diff] |
| 259 | test json-wiki-diff-diff {[string first "+consectetur adipisicing elit" $diff] >= 0} ;#knownBug |
| 260 | #puts [dict get $JR payload diff] |
| 261 | |
| 262 | #### UNAVOIDABLE MISC |
| 263 | |
| 264 | |
| 265 |
| --- test/json.test | |
| +++ test/json.test | |
| @@ -174,10 +174,60 @@ | |
| 174 | [list name uuid user timestamp size] {} |
| 175 | # name, uuid, parent?, user, timestamp, size?, content? |
| 176 | |
| 177 | |
| 178 | #### AUTHENTICATION |
| 179 | fossil_json anonymousPassword |
| 180 | test_json_envelope_ok json-anonymousPassword-env |
| 181 | test_json_payload json-anonymousPassword {seed password} {} |
| 182 | set seed [dict get $JR payload seed] |
| 183 | set pass [dict get $JR payload password] |
| 184 | |
| 185 | write_file anon-1 [subst { |
| 186 | { |
| 187 | "command":"login", |
| 188 | "payload":{ |
| 189 | "name":"anonymous", |
| 190 | "anonymousSeed":$seed, |
| 191 | "password":"$pass" |
| 192 | } |
| 193 | } |
| 194 | }] |
| 195 | fossil_json --json-input anon-1 |
| 196 | test_json_envelope_ok json-login-a-env |
| 197 | test_json_payload json-login-a {authToken name capabilities loginCookieName} {} |
| 198 | set AuthAnon [dict get $JR payload] |
| 199 | |
| 200 | fossil user new U1 User-1 Uone |
| 201 | fossil user capabilities U1 s |
| 202 | write_file u1 { |
| 203 | { |
| 204 | "command":"login", |
| 205 | "payload":{ |
| 206 | "name":"U1", |
| 207 | "password":"Uone" |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | fossil_json --json-input u1 |
| 212 | test_json_envelope_ok json-login-u1-env |
| 213 | test_json_payload json-login-u1 {authToken name capabilities loginCookieName} {} |
| 214 | set AuthU1 [dict get $JR payload] |
| 215 | #puts $AuthAnon |
| 216 | #puts $AuthU1 |
| 217 | |
| 218 | # json cap |
| 219 | # Bug? The CLI user has all rights, and no auth token affects that. |
| 220 | write_file u2 [subst { |
| 221 | {"command":"cap", |
| 222 | "authToken":"[dict get $AuthAnon]" |
| 223 | } |
| 224 | }] |
| 225 | fossil_json --json-input u2 |
| 226 | test_json_envelope_ok json-cap-env |
| 227 | #puts [dict get $JR payload] |
| 228 | |
| 229 | #### BRANCHES |
| 230 | #### CONFIG |
| 231 | #### DIFFS |
| 232 | #### DIRECTORY LISTING |
| 233 | #### FILE INFO |
| @@ -254,11 +304,47 @@ | |
| 304 | test_json_envelope_ok json-wiki-diff-env |
| 305 | test_json_payload json-wiki-diff [list v1 v2 diff] {} |
| 306 | test json-wiki-diff-v1 {[dict get $JR payload v1] eq $uuid1} |
| 307 | test json-wiki-diff-v1 {[dict get $JR payload v2] eq $uuid2} |
| 308 | set diff [dict get $JR payload diff] |
| 309 | test json-wiki-diff-diff {[string first "+consectetur adipisicing elit" $diff] >= 0} knownBug |
| 310 | #puts [dict get $JR payload diff] |
| 311 | |
| 312 | # wiki preview |
| 313 | # |
| 314 | # takes a string in fossil wiki markup and return an HTML fragment. |
| 315 | # This command does not make use of the actual wiki content (much?) |
| 316 | # at all. |
| 317 | write_file req3.json { |
| 318 | { |
| 319 | "command":"wiki/preview", |
| 320 | "payload":"Lorem ipsum dolor sic amet.\nconsectetur adipisicing elit." |
| 321 | } |
| 322 | } |
| 323 | fossil_json --json-input req3.json |
| 324 | test_json_envelope_ok json-wiki-preview-env |
| 325 | set pv [dict get $JR payload] |
| 326 | test json-wiki-preview-out-1 {[string first "<p>Lorem ipsum" $pv] == 0} |
| 327 | test json-wiki-preview-out-2 {[string last "<p>" $pv] == 0} |
| 328 | |
| 329 | #### UNAVOIDABLE MISC |
| 330 | |
| 331 | # json g |
| 332 | fossil_json g |
| 333 | test_json_envelope_ok json-g-env |
| 334 | #puts [llength [dict keys [dict get $JR payload]]] |
| 335 | test json-g-g {[llength [dict keys [dict get $JR payload]]] >= 60};# 64 on my PC |
| 336 | |
| 337 | # json rebuild |
| 338 | fossil_json rebuild |
| 339 | test_json_envelope json-rebuild-env [concat fossil timestamp command procTimeUs \ |
| 340 | procTimeMs] [concat payload resultCode resultText] |
| 341 | |
| 342 | # json resultCodes |
| 343 | fossil_json resultCodes |
| 344 | test_json_envelope_ok json-resultCodes-env |
| 345 | set codes [dict get $JR payload] |
| 346 | test json-resultCodes-codes-1 {[llength $codes] >= 35} ;# count as of API 20120713 |
| 347 | # foreach c $codes { |
| 348 | # puts [dict values $c] |
| 349 | # } |
| 350 | |
| 351 |