summaryrefslogtreecommitdiffstats
path: root/debian/vendor-h2o/t/50mruby-acl.t
blob: 0c84a68211da8701546fcf5ca1562b14cdc7f3bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use Test::More;
use Test::Exception;
use t::Util;

plan skip_all => 'mruby support is off'
    unless server_features()->{mruby};

subtest "invalid configuration 1" => sub {
    throws_ok sub {
        spawn_h2o(<< 'EOT');
hosts:
  default:
    paths:
      /:
        mruby.handler: |
          acl { respond(403) }
          acl { respond(200) }
EOT
    }, qr/server failed to start/, 'acl cannot be called more than once';
};

subtest "invalid configuration 2" => sub {
    throws_ok sub {
        spawn_h2o(<< 'EOT');
hosts:
  default:
    paths:
      /:
        mruby.handler: |
          acl { respond(403) }
          proc {|env| [200, {}, []]}
EOT
    }, qr/server failed to start/, 'acl configuration is ignored';
};

done_testing();