File: 81-submit.t

package info (click to toggle)
librt-client-rest-perl 1%3A0.72-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 588 kB
  • sloc: perl: 4,883; makefile: 9
file content (56 lines) | stat: -rw-r--r-- 982 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!perl
# vim:ft=perl:
#
# This script tests whether submited data looks good

use strict;
use warnings;

use Test::More;

use IO::Socket;
use RT::Client::REST;

my $server = IO::Socket::INET->new(
    Type   => SOCK_STREAM,
    Reuse  => 1,
    Listen => 10,
) or die "Could not set up TCP server: $@";

my $port = $server->sockport;

my $pid = fork;
die "cannot fork: $!" unless defined $pid;

if ( 0 == $pid ) {    # Child
    my $buf;
    my $client = $server->accept;
    $client->write(
        "RT/42foo 200 this is a fake successful response header
header line 1
header line 2

response text"
    );
    exit;
}

plan tests => 1;
my $rt = RT::Client::REST->new(
    server  => "http://127.0.0.1:$port",
    timeout => 2,
);
my $res = $rt->_submit(
    'ticket/1',
    undef,
    {
        user => 'a',
        pass => 'b',
    }
);
unlike(
    $res->{_content},
    qr/this is a fake successful response header/,
    'Make sure response content doesn\'t contain headers'
);