test-http.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. # Copyright (C) 2014 Jakob Borg and other contributors. All rights reserved.
  3. # Use of this source code is governed by an MIT-style license that can be
  4. # found in the LICENSE file.
  5. id1=I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU
  6. id2=JMFJCXB-GZDE4BN-OCJE3VF-65GYZNU-AIVJRET-3J6HMRQ-AUQIGJO-FKNHMQU
  7. id3=373HSRP-QLPNLIE-JYKZVQF-P4PKZ63-R2ZE6K3-YD442U2-JHBGBQG-WWXAHAU
  8. stop() {
  9. echo Stopping
  10. curl -s -o/dev/null -HX-API-Key:abc123 -X POST http://localhost:8081/rest/shutdown
  11. curl -s -o/dev/null -HX-API-Key:abc123 -X POST http://localhost:8082/rest/shutdown
  12. exit $1
  13. }
  14. echo Building
  15. go build http.go
  16. echo Starting
  17. rm -rf s1 s2 h1/index h2/index
  18. syncthing -home h1 > 1.out 2>&1 &
  19. syncthing -home h2 > 2.out 2>&1 &
  20. sleep 1
  21. echo Fetching CSRF tokens
  22. curl -s -o /dev/null http://testuser:testpass@localhost:8081/index.html
  23. curl -s -o /dev/null http://localhost:8082/index.html
  24. sleep 1
  25. echo Testing
  26. ./http -target localhost:8081 -user testuser -pass testpass -csrf h1/csrftokens.txt || stop 1
  27. ./http -target localhost:8081 -api abc123 || stop 1
  28. ./http -target localhost:8082 -csrf h2/csrftokens.txt || stop 1
  29. ./http -target localhost:8082 -api abc123 || stop 1
  30. stop 0