Lines 62-68
subtest 'list() tests' => sub {
Link Here
|
62 |
|
62 |
|
63 |
## Authorized user tests |
63 |
## Authorized user tests |
64 |
# No additional fields, so empty array should be returned |
64 |
# No additional fields, so empty array should be returned |
65 |
$t->get_ok("//$userid:$password@/api/v1/additional_fields")->status_is(200)->json_is( [] ); |
65 |
$t->get_ok("//$userid:$password@/api/v1/extended_attribute_types")->status_is(200)->json_is( [] ); |
66 |
|
66 |
|
67 |
my $additional_field = $builder->build_object( |
67 |
my $additional_field = $builder->build_object( |
68 |
{ |
68 |
{ |
Lines 72-78
subtest 'list() tests' => sub {
Link Here
|
72 |
); |
72 |
); |
73 |
|
73 |
|
74 |
# One additional_field created, should get returned |
74 |
# One additional_field created, should get returned |
75 |
$t->get_ok("//$userid:$password@/api/v1/additional_fields")->status_is(200) |
75 |
$t->get_ok("//$userid:$password@/api/v1/extended_attribute_types")->status_is(200) |
76 |
->json_is( [ $additional_field->to_api ] ); |
76 |
->json_is( [ $additional_field->to_api ] ); |
77 |
|
77 |
|
78 |
my $another_additional_field = $builder->build_object( |
78 |
my $another_additional_field = $builder->build_object( |
Lines 90-96
subtest 'list() tests' => sub {
Link Here
|
90 |
); |
90 |
); |
91 |
|
91 |
|
92 |
# Three additional fields created, they should both be returned |
92 |
# Three additional fields created, they should both be returned |
93 |
$t->get_ok("//$userid:$password@/api/v1/additional_fields")->status_is(200)->json_is( |
93 |
$t->get_ok("//$userid:$password@/api/v1/extended_attribute_types")->status_is(200)->json_is( |
94 |
[ |
94 |
[ |
95 |
$additional_field->to_api, |
95 |
$additional_field->to_api, |
96 |
$another_additional_field->to_api, |
96 |
$another_additional_field->to_api, |
Lines 99-113
subtest 'list() tests' => sub {
Link Here
|
99 |
); |
99 |
); |
100 |
|
100 |
|
101 |
# Filtering works, two existing additional fields returned for the queried table name |
101 |
# Filtering works, two existing additional fields returned for the queried table name |
102 |
$t->get_ok( "//$userid:$password@/api/v1/additional_fields?table_name=" . $additional_field->tablename ) |
102 |
$t->get_ok("//$userid:$password@/api/v1/extended_attribute_types?resource_type=invoice")->status_is(200) |
103 |
->status_is(200)->json_is( [ $additional_field->to_api, $another_additional_field->to_api ] ); |
103 |
->json_is( [ $additional_field->to_api, $another_additional_field->to_api ] ); |
104 |
|
104 |
|
105 |
# Warn on unsupported query parameter |
105 |
# Warn on unsupported query parameter |
106 |
$t->get_ok("//$userid:$password@/api/v1/additional_fields?blah=blah")->status_is(400) |
106 |
$t->get_ok("//$userid:$password@/api/v1/extended_attribute_types?blah=blah")->status_is(400) |
107 |
->json_is( [ { path => '/query/blah', message => 'Malformed query string' } ] ); |
107 |
->json_is( [ { path => '/query/blah', message => 'Malformed query string' } ] ); |
108 |
|
108 |
|
109 |
# Unauthorized access |
109 |
# Unauthorized access |
110 |
$t->get_ok("//$unauth_userid:$password@/api/v1/additional_fields")->status_is(403); |
110 |
$t->get_ok("//$unauth_userid:$password@/api/v1/extended_attribute_types")->status_is(403); |
111 |
|
111 |
|
112 |
$schema->storage->txn_rollback; |
112 |
$schema->storage->txn_rollback; |
113 |
}; |
113 |
}; |
114 |
- |
|
|