t / t9501-gitweb-standalone-http-status.shon commit Git 1.6.6.3 (abf411e)
   1#!/bin/sh
   2#
   3# Copyright (c) 2009 Mark Rada
   4#
   5
   6test_description='gitweb as standalone script (http status tests).
   7
   8This test runs gitweb (git web interface) as a CGI script from the
   9commandline, and checks that it returns the expected HTTP status
  10code and message.'
  11
  12
  13. ./gitweb-lib.sh
  14
  15# ----------------------------------------------------------------------
  16# snapshot settings
  17
  18test_commit \
  19        'SnapshotTests' \
  20        'i can has snapshot?'
  21
  22cat >>gitweb_config.perl <<\EOF
  23$feature{'snapshot'}{'override'} = 0;
  24EOF
  25
  26test_expect_success \
  27    'snapshots: tgz only default format enabled' \
  28    'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
  29    grep "Status: 200 OK" gitweb.output &&
  30    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
  31    grep "403 - Unsupported snapshot format" gitweb.output &&
  32    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
  33    grep "403 - Snapshot format not allowed" gitweb.output &&
  34    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
  35    grep "403 - Unsupported snapshot format" gitweb.output'
  36test_debug 'cat gitweb.output'
  37
  38
  39cat >>gitweb_config.perl <<\EOF
  40$feature{'snapshot'}{'default'} = ['tgz','tbz2','txz','zip'];
  41EOF
  42
  43test_expect_success \
  44    'snapshots: all enabled in default, use default disabled value' \
  45    'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
  46    grep "Status: 200 OK" gitweb.output &&
  47    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
  48    grep "Status: 200 OK" gitweb.output &&
  49    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
  50    grep "403 - Snapshot format not allowed" gitweb.output &&
  51    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
  52    grep "Status: 200 OK" gitweb.output'
  53test_debug 'cat gitweb.output'
  54
  55
  56cat >>gitweb_config.perl <<\EOF
  57$known_snapshot_formats{'zip'}{'disabled'} = 1;
  58EOF
  59
  60test_expect_success \
  61    'snapshots: zip explicitly disabled' \
  62    'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
  63    grep "403 - Snapshot format not allowed" gitweb.output'
  64test_debug 'cat gitweb.output'
  65
  66
  67cat >>gitweb_config.perl <<\EOF
  68$known_snapshot_formats{'tgz'}{'disabled'} = 0;
  69EOF
  70
  71test_expect_success \
  72    'snapshots: tgz explicitly enabled' \
  73    'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
  74    grep "Status: 200 OK" gitweb.output'
  75test_debug 'cat gitweb.output'
  76
  77
  78# ----------------------------------------------------------------------
  79# snapshot hash ids
  80
  81test_expect_success 'snapshots: good tree-ish id' '
  82        gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" &&
  83        grep "Status: 200 OK" gitweb.output
  84'
  85test_debug 'cat gitweb.output'
  86
  87test_expect_success 'snapshots: bad tree-ish id' '
  88        gitweb_run "p=.git;a=snapshot;h=frizzumFrazzum;sf=tgz" &&
  89        grep "404 - Object does not exist" gitweb.output
  90'
  91test_debug 'cat gitweb.output'
  92
  93test_expect_success 'snapshots: bad tree-ish id (tagged object)' '
  94        echo object > tag-object &&
  95        git add tag-object &&
  96        git commit -m "Object to be tagged" &&
  97        git tag tagged-object `git hash-object tag-object` &&
  98        gitweb_run "p=.git;a=snapshot;h=tagged-object;sf=tgz" &&
  99        grep "400 - Object is not a tree-ish" gitweb.output
 100'
 101test_debug 'cat gitweb.output'
 102
 103test_expect_success 'snapshots: good object id' '
 104        ID=`git rev-parse --verify HEAD` &&
 105        gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
 106        grep "Status: 200 OK" gitweb.output
 107'
 108test_debug 'cat gitweb.output'
 109
 110test_expect_success 'snapshots: bad object id' '
 111        gitweb_run "p=.git;a=snapshot;h=abcdef01234;sf=tgz" &&
 112        grep "404 - Object does not exist" gitweb.output
 113'
 114test_debug 'cat gitweb.output'
 115
 116
 117test_done