MT#6195 api tests adjustments - use is

agranig/selfsignup
Gerhard Jungwirth 11 years ago
parent 6f368e820f
commit 46e5f4431c

@ -26,7 +26,7 @@ $ua->ssl_opts(
$req = HTTP::Request->new('OPTIONS', $uri.'/api/billingfees/');
$res = $ua->request($req);
is($res->code, 200, "check options request");
ok($res->header('Accept-Post') eq "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-billingfees", "check Accept-Post header in options response");
is($res->header('Accept-Post'), "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-billingfees", "check Accept-Post header in options response");
my $opts = JSON::from_json($res->decoded_content);
my @hopts = split /\s*,\s*/, $res->header('Allow');
ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body");
@ -119,7 +119,7 @@ my @allfees = ();
$res = $ua->request($req);
is($res->code, 422, "create profile without billing_profile_id");
my $err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /Invalid 'billing_profile_id'/, "check error message in body");
# try to create fee with invalid billing_profile_id
@ -142,7 +142,7 @@ my @allfees = ();
$res = $ua->request($req);
is($res->code, 422, "create profile with invalid billing_profile_id");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /Invalid 'billing_profile_id'/, "check error message in body");
# try to create fee with missing billing_zone_id
@ -165,7 +165,7 @@ my @allfees = ();
$res = $ua->request($req);
is($res->code, 422, "create profile without billing_zone_id");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='billing_zone_id'/, "check error message in body");
# try to create fee with invalid billing_zone_id
@ -188,7 +188,7 @@ my @allfees = ();
$res = $ua->request($req);
is($res->code, 422, "create profile without billing_profile_id");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /Invalid 'billing_zone_id'/, "check error message in body");
# TODO: check for wrong values in rates, prepaid etc
@ -200,7 +200,7 @@ my @allfees = ();
is($res->code, 200, "fetch fees page");
my $collection = JSON::from_json($res->decoded_content);
my $selfuri = $uri . $collection->{_links}->{self}->{href};
ok($selfuri eq $nexturi, "check _links.self.href of collection");
is($selfuri, $nexturi, "check _links.self.href of collection");
my $colluri = URI->new($selfuri);
ok($collection->{total_count} > 0, "check 'total_count' of collection");
@ -399,9 +399,9 @@ my @allfees = ();
$res = $ua->request($req);
is($res->code, 200, "check patched fee item");
my $mod_fee = JSON::from_json($res->decoded_content);
ok($mod_fee->{direction} eq "in", "check patched replace op");
ok($mod_fee->{_links}->{self}->{href} eq $firstfee, "check patched self link");
ok($mod_fee->{_links}->{collection}->{href} eq '/api/billingfees/', "check patched collection link");
is($mod_fee->{direction}, "in", "check patched replace op");
is($mod_fee->{_links}->{self}->{href}, $firstfee, "check patched self link");
is($mod_fee->{_links}->{collection}->{href}, '/api/billingfees/', "check patched collection link");
$req->content(JSON::to_json(
[ { op => 'replace', path => '/billing_profile_id', value => undef } ]

@ -26,7 +26,7 @@ $ua->ssl_opts(
$req = HTTP::Request->new('OPTIONS', $uri.'/api/billingprofiles/');
$res = $ua->request($req);
is($res->code, 200, "check options request");
ok($res->header('Accept-Post') eq "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-billingprofiles", "check Accept-Post header in options response");
is($res->header('Accept-Post'), "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-billingprofiles", "check Accept-Post header in options response");
my $opts = JSON::from_json($res->decoded_content);
my @hopts = split /\s*,\s*/, $res->header('Allow');
ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body");
@ -69,7 +69,7 @@ my @allprofiles = ();
$res = $ua->request($req);
is($res->code, 422, "create profile without reseller_id");
my $err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='reseller_id'/, "check error message in body");
# try to create profile with empty reseller_id
@ -81,7 +81,7 @@ my @allprofiles = ();
$res = $ua->request($req);
is($res->code, 422, "create profile with empty reseller_id");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='reseller_id'/, "check error message in body");
# try to create profile with invalid reseller_id
@ -93,7 +93,7 @@ my @allprofiles = ();
$res = $ua->request($req);
is($res->code, 422, "create profile with invalid reseller_id");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /Invalid 'reseller_id'/, "check error message in body");
# TODO: check for wrong values in prepaid, fees etc
@ -105,7 +105,7 @@ my @allprofiles = ();
is($res->code, 200, "fetch profile page");
my $collection = JSON::from_json($res->decoded_content);
my $selfuri = $uri . $collection->{_links}->{self}->{href};
ok($selfuri eq $nexturi, "check _links.self.href of collection");
is($selfuri, $nexturi, "check _links.self.href of collection");
my $colluri = URI->new($selfuri);
ok($collection->{total_count} > 0, "check 'total_count' of collection");
@ -240,9 +240,9 @@ my @allprofiles = ();
$res = $ua->request($req);
is($res->code, 200, "check patched profile item");
my $mod_profile = JSON::from_json($res->decoded_content);
ok($mod_profile->{name} eq "patched name $t", "check patched replace op");
ok($mod_profile->{_links}->{self}->{href} eq $firstprofile, "check patched self link");
ok($mod_profile->{_links}->{collection}->{href} eq '/api/billingprofiles/', "check patched collection link");
is($mod_profile->{name}, "patched name $t", "check patched replace op");
is($mod_profile->{_links}->{self}->{href}, $firstprofile, "check patched self link");
is($mod_profile->{_links}->{collection}->{href}, '/api/billingprofiles/', "check patched collection link");
$req->content(JSON::to_json(

@ -28,7 +28,7 @@ $ua->ssl_opts(
$req = HTTP::Request->new('OPTIONS', $uri.'/api/contracts/');
$res = $ua->request($req);
is($res->code, 200, "check options request");
ok($res->header('Accept-Post') eq "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-contracts", "check Accept-Post header in options response");
is($res->header('Accept-Post'), "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-contracts", "check Accept-Post header in options response");
my $opts = JSON::from_json($res->decoded_content);
my @hopts = split /\s*,\s*/, $res->header('Allow');
ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body");
@ -107,7 +107,7 @@ my @allcontracts = ();
$res = $ua->request($req);
is($res->code, 422, "create contract with invalid type");
my $err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /Invalid 'type'/, "check error message in body");
# try to create invalid contract with wrong billing profile
@ -120,7 +120,7 @@ my @allcontracts = ();
$res = $ua->request($req);
is($res->code, 422, "create contract with invalid billing profile");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /Invalid 'billing_profile_id'/, "check error message in body");
# try to create invalid contract with customercontact
@ -133,7 +133,7 @@ my @allcontracts = ();
$res = $ua->request($req);
is($res->code, 422, "create contract with invalid contact");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /The contact_id is not a valid ngcp:systemcontacts item/, "check error message in body");
# try to create invalid contract without contact
@ -155,7 +155,7 @@ my @allcontracts = ();
$res = $ua->request($req);
is($res->code, 422, "create contract with invalid status");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='status'/, "check error message in body");
# iterate over contracts collection to check next/prev links and status
@ -165,7 +165,7 @@ my @allcontracts = ();
is($res->code, 200, "fetch contacts page");
my $collection = JSON::from_json($res->decoded_content);
my $selfuri = $uri . $collection->{_links}->{self}->{href};
ok($selfuri eq $nexturi, "check _links.self.href of collection");
is($selfuri, $nexturi, "check _links.self.href of collection");
my $colluri = URI->new($selfuri);
ok($collection->{total_count} > 0, "check 'total_count' of collection");
@ -306,9 +306,9 @@ my @allcontracts = ();
$res = $ua->request($req);
is($res->code, 200, "check patched contract item");
my $mod_contact = JSON::from_json($res->decoded_content);
ok($mod_contact->{status} eq "pending", "check patched replace op");
ok($mod_contact->{_links}->{self}->{href} eq $firstcontract, "check patched self link");
ok($mod_contact->{_links}->{collection}->{href} eq '/api/contracts/', "check patched collection link");
is($mod_contact->{status}, "pending", "check patched replace op");
is($mod_contact->{_links}->{self}->{href}, $firstcontract, "check patched self link");
is($mod_contact->{_links}->{collection}->{href}, '/api/contracts/', "check patched collection link");
$req->content(JSON::to_json(
@ -366,7 +366,7 @@ my @allcontracts = ();
$res = $ua->request($req);
is($res->code, 200, "check termination of contract");
$pc = JSON::from_json($res->decoded_content);
ok($pc->{status} eq "terminated", "check termination status of contract");
is($pc->{status}, "terminated", "check termination status of contract");
}
# check if we can still get the terminated contract

@ -26,7 +26,7 @@ $ua->ssl_opts(
$req = HTTP::Request->new('OPTIONS', $uri.'/api/customercontacts/');
$res = $ua->request($req);
is($res->code, 200, "check options request");
ok($res->header('Accept-Post') eq "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-customercontacts", "check Accept-Post header in options response");
is($res->header('Accept-Post'), "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-customercontacts", "check Accept-Post header in options response");
my $opts = JSON::from_json($res->decoded_content);
my @hopts = split /\s*,\s*/, $res->header('Allow');
ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body");
@ -82,7 +82,7 @@ my @allcontacts = ();
$res = $ua->request($req);
is($res->code, 422, "create invalid test contact with missing email");
my $email_err = JSON::from_json($res->decoded_content);
ok($email_err->{code} eq "422", "check error code in body");
is($email_err->{code}, "422", "check error code in body");
ok($email_err->{message} =~ /field=\'email\'/, "check error message in body");
# try to create invalid contact without reseller_id
$req->content(JSON::to_json({
@ -94,7 +94,7 @@ my @allcontacts = ();
$res = $ua->request($req);
is($res->code, 422, "create invalid test contact with missing reseller_id");
$email_err = JSON::from_json($res->decoded_content);
ok($email_err->{code} eq "422", "check error code in body");
is($email_err->{code}, "422", "check error code in body");
ok($email_err->{message} =~ /field=\'reseller_id\'/, "check error message in body");
# try to create invalid contact with invalid reseller_id
@ -107,7 +107,7 @@ my @allcontacts = ();
$res = $ua->request($req);
is($res->code, 422, "create invalid test contact with invalid reseller_id");
$email_err = JSON::from_json($res->decoded_content);
ok($email_err->{code} eq "422", "check error code in body");
is($email_err->{code}, "422", "check error code in body");
ok($email_err->{message} =~ /Invalid \'reseller_id\'/, "check error message in body");
# iterate over contacts collection to check next/prev links
@ -117,7 +117,7 @@ my @allcontacts = ();
is($res->code, 200, "fetch contacts page");
my $collection = JSON::from_json($res->decoded_content);
my $selfuri = $uri . $collection->{_links}->{self}->{href};
ok($selfuri eq $nexturi, "check _links.self.href of collection");
is($selfuri, $nexturi, "check _links.self.href of collection");
my $colluri = URI->new($selfuri);
ok($collection->{total_count} > 0, "check 'total_count' of collection");
@ -238,7 +238,7 @@ my @allcontacts = ();
$res = $ua->request($req);
is($res->code, 200, "check patched contact item");
my $mod_contact = JSON::from_json($res->decoded_content);
ok($mod_contact->{firstname} eq "patchedfirst", "check patched replace op");
is($mod_contact->{firstname}, "patchedfirst", "check patched replace op");
$req->content(JSON::to_json(
[ { op => 'replace', path => '/firstname', value => undef } ]

@ -28,7 +28,7 @@ $ua->ssl_opts(
$req = HTTP::Request->new('OPTIONS', $uri.'/api/customers/');
$res = $ua->request($req);
is($res->code, 200, "check options request");
ok($res->header('Accept-Post') eq "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-customers", "check Accept-Post header in options response");
is($res->header('Accept-Post'), "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-customers", "check Accept-Post header in options response");
my $opts = JSON::from_json($res->decoded_content);
my @hopts = split /\s*,\s*/, $res->header('Allow');
ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body");
@ -117,7 +117,7 @@ my @allcustomers = ();
$res = $ua->request($req);
is($res->code, 422, "create customer with invalid type");
my $err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /Invalid 'type'/, "check error message in body");
# try to create invalid customer with wrong billing profile
@ -132,7 +132,7 @@ my @allcustomers = ();
$res = $ua->request($req);
is($res->code, 422, "create customer with invalid billing profile");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /Invalid 'billing_profile_id'/, "check error message in body");
# try to create invalid customer with systemcontact
@ -147,7 +147,7 @@ my @allcustomers = ();
$res = $ua->request($req);
is($res->code, 422, "create customer with invalid contact");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /The contact_id is not a valid ngcp:customercontacts item/, "check error message in body");
# try to create invalid customer without contact
@ -173,7 +173,7 @@ my @allcustomers = ();
$res = $ua->request($req);
is($res->code, 422, "create customer with invalid status");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='status'/, "check error message in body");
# try to create invalid customer with invalid max_subscribers
@ -188,7 +188,7 @@ my @allcustomers = ();
$res = $ua->request($req);
is($res->code, 422, "create customer with invalid max_subscribers");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='max_subscribers'/, "check error message in body");
# iterate over customers collection to check next/prev links and status
@ -198,7 +198,7 @@ my @allcustomers = ();
is($res->code, 200, "fetch contacts page");
my $collection = JSON::from_json($res->decoded_content);
my $selfuri = $uri . $collection->{_links}->{self}->{href};
ok($selfuri eq $nexturi, "check _links.self.href of collection");
is($selfuri, $nexturi, "check _links.self.href of collection");
my $colluri = URI->new($selfuri);
ok($collection->{total_count} > 0, "check 'total_count' of collection");
@ -340,9 +340,9 @@ my @allcustomers = ();
$res = $ua->request($req);
is($res->code, 200, "check patched customer item");
my $mod_contact = JSON::from_json($res->decoded_content);
ok($mod_contact->{status} eq "pending", "check patched replace op");
ok($mod_contact->{_links}->{self}->{href} eq $firstcustomer, "check patched self link");
ok($mod_contact->{_links}->{collection}->{href} eq '/api/customers/', "check patched collection link");
is($mod_contact->{status}, "pending", "check patched replace op");
is($mod_contact->{_links}->{self}->{href}, $firstcustomer, "check patched self link");
is($mod_contact->{_links}->{collection}->{href}, '/api/customers/', "check patched collection link");
$req->content(JSON::to_json(
@ -406,7 +406,7 @@ my @allcustomers = ();
$res = $ua->request($req);
is($res->code, 200, "check termination of customer");
$pc = JSON::from_json($res->decoded_content);
ok($pc->{status} eq "terminated", "check termination status of customer");
is($pc->{status}, "terminated", "check termination status of customer");
}
# check if we can still get the terminated customer

@ -26,7 +26,7 @@ $ua->ssl_opts(
$req = HTTP::Request->new('OPTIONS', $uri.'/api/resellers/');
$res = $ua->request($req);
is($res->code, 200, "check options request");
ok($res->header('Accept-Post') eq "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-resellers", "check Accept-Post header in options response");
is($res->header('Accept-Post'), "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-resellers", "check Accept-Post header in options response");
my $opts = JSON::from_json($res->decoded_content);
my @hopts = split /\s*,\s*/, $res->header('Allow');
ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body");
@ -116,7 +116,7 @@ my @allresellers = ();
$res = $ua->request($req);
is($res->code, 422, "create reseller without contract_id");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='contract_id'/, "check error message in body");
# try to create reseller with empty contract_id
@ -128,7 +128,7 @@ my @allresellers = ();
$res = $ua->request($req);
is($res->code, 422, "create reseller with empty contract_id");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='contract_id'/, "check error message in body");
# try to create reseller with existing contract_id
@ -140,7 +140,7 @@ my @allresellers = ();
$res = $ua->request($req);
is($res->code, 422, "create reseller with existing contract_id");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /reseller with this contract already exists/, "check error message in body");
# try to create reseller with existing name
@ -152,7 +152,7 @@ my @allresellers = ();
$res = $ua->request($req);
is($res->code, 422, "create reseller with existing name");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /reseller with this name already exists/, "check error message in body");
# try to create reseller with missing name
@ -163,7 +163,7 @@ my @allresellers = ();
$res = $ua->request($req);
is($res->code, 422, "create reseller with missing name");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='name'/, "check error message in body");
# try to create reseller with missing status
@ -174,7 +174,7 @@ my @allresellers = ();
$res = $ua->request($req);
is($res->code, 422, "create reseller with invalid status");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='status'/, "check error message in body");
# try to create reseller with invalid status
@ -186,7 +186,7 @@ my @allresellers = ();
$res = $ua->request($req);
is($res->code, 422, "create reseller with invalid status");
$err = JSON::from_json($res->decoded_content);
ok($err->{code} eq "422", "check error code in body");
is($err->{code}, "422", "check error code in body");
ok($err->{message} =~ /field='status'/, "check error message in body");
# iterate over collection to check next/prev links and status
@ -196,7 +196,7 @@ my @allresellers = ();
is($res->code, 200, "fetch reseller page");
my $collection = JSON::from_json($res->decoded_content);
my $selfuri = $uri . $collection->{_links}->{self}->{href};
ok($selfuri eq $nexturi, "check _links.self.href of collection");
is($selfuri, $nexturi, "check _links.self.href of collection");
my $colluri = URI->new($selfuri);
ok($collection->{total_count} > 0, "check 'total_count' of collection");
@ -328,9 +328,9 @@ my @allresellers = ();
$res = $ua->request($req);
is($res->code, 200, "check patched reseller item");
my $mod_reseller = JSON::from_json($res->decoded_content);
ok($mod_reseller->{name} eq "patched name $t", "check patched replace op");
ok($mod_reseller->{_links}->{self}->{href} eq $firstreseller, "check patched self link");
ok($mod_reseller->{_links}->{collection}->{href} eq '/api/resellers/', "check patched collection link");
is($mod_reseller->{name}, "patched name $t", "check patched replace op");
is($mod_reseller->{_links}->{self}->{href}, $firstreseller, "check patched self link");
is($mod_reseller->{_links}->{collection}->{href}, '/api/resellers/', "check patched collection link");
$req->content(JSON::to_json(
[ { op => 'replace', path => '/contract_id', value => undef } ]

@ -26,7 +26,7 @@ $ua->ssl_opts(
$req = HTTP::Request->new('OPTIONS', $uri.'/api/rewriterulesets/');
$res = $ua->request($req);
is($res->code, 200, "check options request");
ok($res->header('Accept-Post') eq "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-rewriterulesets", "check Accept-Post header in options response");
is($res->header('Accept-Post'), "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-rewriterulesets", "check Accept-Post header in options response");
my $opts = JSON::from_json($res->decoded_content);
my @hopts = split /\s*,\s*/, $res->header('Allow');
ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body");
@ -204,7 +204,7 @@ my @allrules = ();
is($res->code, 200, "fetch rules page");
my $collection = JSON::from_json($res->decoded_content);
my $selfuri = $uri . $collection->{_links}->{self}->{href};
ok($selfuri eq $nexturi, "check _links.self.href of collection");
is($selfuri, $nexturi, "check _links.self.href of collection");
my $colluri = URI->new($selfuri);
ok($collection->{total_count} > 0, "check 'total_count' of collection");

@ -26,7 +26,7 @@ $ua->ssl_opts(
$req = HTTP::Request->new('OPTIONS', $uri.'/api/systemcontacts/');
$res = $ua->request($req);
is($res->code, 200, "check options request");
ok($res->header('Accept-Post') eq "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-systemcontacts", "check Accept-Post header in options response");
is($res->header('Accept-Post'), "application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-systemcontacts", "check Accept-Post header in options response");
my $opts = JSON::from_json($res->decoded_content);
my @hopts = split /\s*,\s*/, $res->header('Allow');
ok(exists $opts->{methods} && ref $opts->{methods} eq "ARRAY", "check for valid 'methods' in body");
@ -67,7 +67,7 @@ my @allcontacts = ();
$res = $ua->request($req);
is($res->code, 422, "create invalid test contact with missing email");
my $email_err = JSON::from_json($res->decoded_content);
ok($email_err->{code} eq "422", "check error code in body");
is($email_err->{code}, "422", "check error code in body");
ok($email_err->{message} =~ /field=\'email\'/, "check error message in body");
# iterate over contacts collection to check next/prev links
@ -77,7 +77,7 @@ my @allcontacts = ();
is($res->code, 200, "fetch contacts page");
my $collection = JSON::from_json($res->decoded_content);
my $selfuri = $uri . $collection->{_links}->{self}->{href};
ok($selfuri eq $nexturi, "check _links.self.href of collection");
is($selfuri, $nexturi, "check _links.self.href of collection");
my $colluri = URI->new($selfuri);
ok($collection->{total_count} > 0, "check 'total_count' of collection");
@ -207,7 +207,7 @@ my @allcontacts = ();
$res = $ua->request($req);
is($res->code, 200, "check patched contact item");
my $mod_contact = JSON::from_json($res->decoded_content);
ok($mod_contact->{firstname} eq "patchedfirst", "check patched replace op");
is($mod_contact->{firstname}, "patchedfirst", "check patched replace op");
$req->content(JSON::to_json(
[ { op => 'replace', path => '/firstname', value => undef } ]

Loading…
Cancel
Save