- Optional "role" parameter is added for POST PUT PATCH. If "role" is provided then the passed flags are ignored and are applied internally by the server according to the provided role. If "role" is not provided then the former flags based approach is applied. Change-Id: Ib6e591ff6dc50122e0ec49a348153ca820fc2e03mr10.3
parent
aac3a16e5e
commit
9855b6ab45
@ -0,0 +1,29 @@
|
||||
package NGCP::Panel::Form::Administrator::AdminAPI;
|
||||
|
||||
use HTML::FormHandler::Moose;
|
||||
extends 'NGCP::Panel::Form::Administrator::Admin';
|
||||
|
||||
use Storable qw();
|
||||
|
||||
has_field 'role' => (
|
||||
type => 'Text'
|
||||
);
|
||||
|
||||
sub validate {
|
||||
my $self = shift;
|
||||
|
||||
my $c = $self->ctx;
|
||||
return unless $c;
|
||||
|
||||
my $resource = Storable::dclone($self->values);
|
||||
|
||||
if (defined $resource->{role} && ! ref $resource->{role}) {
|
||||
if (!defined NGCP::Panel::Utils::UserRole::name_to_flags($resource->{role})) {
|
||||
my $err = 'Unknown role: ' . $resource->{role};
|
||||
$c->log->error($err);
|
||||
$self->field('role')->add_error($err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,29 @@
|
||||
package NGCP::Panel::Form::Administrator::LInterceptAPI;
|
||||
|
||||
use HTML::FormHandler::Moose;
|
||||
extends 'NGCP::Panel::Form::Administrator::LIntercept';
|
||||
|
||||
use Storable qw();
|
||||
|
||||
has_field 'role' => (
|
||||
type => 'Text'
|
||||
);
|
||||
|
||||
sub validate {
|
||||
my $self = shift;
|
||||
|
||||
my $c = $self->ctx;
|
||||
return unless $c;
|
||||
|
||||
my $resource = Storable::dclone($self->values);
|
||||
|
||||
if (defined $resource->{role} && ! ref $resource->{role}) {
|
||||
if (!defined NGCP::Panel::Utils::UserRole::name_to_flags($resource->{role})) {
|
||||
my $err = 'Unknown role: ' . $resource->{role};
|
||||
$c->log->error($err);
|
||||
$self->field('role')->add_error($err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,29 @@
|
||||
package NGCP::Panel::Form::Administrator::ResellerAPI;
|
||||
|
||||
use HTML::FormHandler::Moose;
|
||||
extends 'NGCP::Panel::Form::Administrator::Reseller';
|
||||
|
||||
use Storable qw();
|
||||
|
||||
has_field 'role' => (
|
||||
type => 'Text'
|
||||
);
|
||||
|
||||
sub validate {
|
||||
my $self = shift;
|
||||
|
||||
my $c = $self->ctx;
|
||||
return unless $c;
|
||||
|
||||
my $resource = Storable::dclone($self->values);
|
||||
|
||||
if (defined $resource->{role} && ! ref $resource->{role}) {
|
||||
if (!defined NGCP::Panel::Utils::UserRole::name_to_flags($resource->{role})) {
|
||||
my $err = 'Unknown role: ' . $resource->{role};
|
||||
$c->log->error($err);
|
||||
$self->field('role')->add_error($err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,31 @@
|
||||
package NGCP::Panel::Form::Administrator::SystemAPI;
|
||||
|
||||
use HTML::FormHandler::Moose;
|
||||
extends 'NGCP::Panel::Form::Administrator::System';
|
||||
|
||||
use Storable qw();
|
||||
|
||||
has_field 'role' => (
|
||||
type => 'Text'
|
||||
);
|
||||
|
||||
sub validate {
|
||||
my $self = shift;
|
||||
|
||||
$self->SUPER::validate(@_);
|
||||
|
||||
my $c = $self->ctx;
|
||||
return unless $c;
|
||||
|
||||
my $resource = Storable::dclone($self->values);
|
||||
|
||||
if (defined $resource->{role} && ! ref $resource->{role}) {
|
||||
if (!defined NGCP::Panel::Utils::UserRole::name_to_flags($resource->{role})) {
|
||||
my $err = 'Unknown role: ' . $resource->{role};
|
||||
$c->log->error($err);
|
||||
$self->field('role')->add_error($err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,228 @@
|
||||
---
|
||||
|
||||
-
|
||||
name: check OPTIONS for admins
|
||||
type: item
|
||||
method: OPTIONS
|
||||
path: /api/admins/
|
||||
conditions:
|
||||
is:
|
||||
code: 200
|
||||
header:
|
||||
Accept-Post: application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-admins
|
||||
ok:
|
||||
options:
|
||||
- GET
|
||||
- POST
|
||||
- OPTIONS
|
||||
- HEAD
|
||||
|
||||
-
|
||||
name: create admin - role admin
|
||||
type: item
|
||||
thread: 1
|
||||
method: POST
|
||||
path: /api/admins/
|
||||
header:
|
||||
Content-Type: application/json
|
||||
Prefer: return=representation
|
||||
content:
|
||||
login: test_login_${unique_id}
|
||||
password: password
|
||||
role: admin
|
||||
reseller_id: 1
|
||||
conditions:
|
||||
is:
|
||||
code: 201
|
||||
retain:
|
||||
admin_path: header.location
|
||||
admin_id: header.location
|
||||
|
||||
-
|
||||
name: get admin - role admin
|
||||
type: item
|
||||
method: GET
|
||||
path: '/${admin_path}'
|
||||
retain:
|
||||
admin: body
|
||||
conditions:
|
||||
is:
|
||||
code: 200
|
||||
'${admin}.is_system': 0
|
||||
'${admin}.is_superuser': 1
|
||||
'${admin}.is_ccare': 0
|
||||
'${admin}.lawful_intercept': 0
|
||||
'${admin}.role': admin
|
||||
ok:
|
||||
'${admin}.login': defined
|
||||
'${admin}.role_id': undefined
|
||||
|
||||
-
|
||||
name: put admin - to role system
|
||||
type: item
|
||||
thread: 1
|
||||
method: PUT
|
||||
path: '/${admin_path}'
|
||||
header:
|
||||
Content-Type: application/json
|
||||
Prefer: return=representation
|
||||
content:
|
||||
login: test_login_${unique_id}
|
||||
role: system
|
||||
reseller_id: 1
|
||||
retain:
|
||||
admin: body
|
||||
conditions:
|
||||
is:
|
||||
code: 200
|
||||
'${admin}.is_system': 1
|
||||
'${admin}.is_superuser': 0
|
||||
'${admin}.is_ccare': 0
|
||||
'${admin}.lawful_intercept': 0
|
||||
|
||||
-
|
||||
name: put admin - to role ccareadmin
|
||||
type: item
|
||||
thread: 1
|
||||
method: PUT
|
||||
path: '/${admin_path}'
|
||||
header:
|
||||
Content-Type: application/json
|
||||
Prefer: return=representation
|
||||
content:
|
||||
login: test_login_${unique_id}
|
||||
role: ccareadmin
|
||||
reseller_id: 1
|
||||
retain:
|
||||
admin: body
|
||||
conditions:
|
||||
is:
|
||||
code: 200
|
||||
'${admin}.is_system': 0
|
||||
'${admin}.is_superuser': 1
|
||||
'${admin}.is_ccare': 1
|
||||
'${admin}.lawful_intercept': 0
|
||||
|
||||
-
|
||||
name: put admin - to role ccare
|
||||
type: item
|
||||
thread: 1
|
||||
method: PUT
|
||||
path: '/${admin_path}'
|
||||
header:
|
||||
Content-Type: application/json
|
||||
Prefer: return=representation
|
||||
content:
|
||||
login: test_login_${unique_id}
|
||||
role: ccare
|
||||
reseller_id: 1
|
||||
retain:
|
||||
admin: body
|
||||
conditions:
|
||||
is:
|
||||
code: 200
|
||||
'${admin}.is_system': 0
|
||||
'${admin}.is_superuser': 0
|
||||
'${admin}.is_ccare': 1
|
||||
'${admin}.lawful_intercept': 0
|
||||
|
||||
-
|
||||
name: put admin - to role lintercept
|
||||
type: item
|
||||
thread: 1
|
||||
method: PUT
|
||||
path: '/${admin_path}'
|
||||
header:
|
||||
Content-Type: application/json
|
||||
Prefer: return=representation
|
||||
content:
|
||||
login: test_login_${unique_id}
|
||||
role: lintercept
|
||||
reseller_id: 1
|
||||
retain:
|
||||
admin: body
|
||||
conditions:
|
||||
is:
|
||||
code: 200
|
||||
'${admin}.is_system': 0
|
||||
'${admin}.is_superuser': 0
|
||||
'${admin}.is_ccare': 0
|
||||
'${admin}.lawful_intercept': 1
|
||||
|
||||
-
|
||||
name: put admin - to role reseller
|
||||
type: item
|
||||
thread: 1
|
||||
method: PUT
|
||||
path: '/${admin_path}'
|
||||
header:
|
||||
Content-Type: application/json
|
||||
Prefer: return=representation
|
||||
content:
|
||||
login: test_login_${unique_id}
|
||||
role: reseller
|
||||
reseller_id: 1
|
||||
retain:
|
||||
admin: body
|
||||
conditions:
|
||||
is:
|
||||
code: 200
|
||||
'${admin}.is_system': 0
|
||||
'${admin}.is_superuser': 0
|
||||
'${admin}.is_ccare': 0
|
||||
'${admin}.lawful_intercept': 0
|
||||
|
||||
-
|
||||
name: put admin - no role, is_system flag
|
||||
type: item
|
||||
thread: 1
|
||||
method: PUT
|
||||
path: '/${admin_path}'
|
||||
header:
|
||||
Content-Type: application/json
|
||||
Prefer: return=representation
|
||||
content:
|
||||
login: test_login_${unique_id}
|
||||
reseller_id: 1
|
||||
is_system: 1
|
||||
retain:
|
||||
admin: body
|
||||
conditions:
|
||||
is:
|
||||
code: 200
|
||||
'${admin}.is_system': 1
|
||||
'${admin}.is_superuser': 0
|
||||
'${admin}.is_ccare': 0
|
||||
'${admin}.lawful_intercept': 0
|
||||
|
||||
-
|
||||
name: patch admin - to role admin
|
||||
type: item
|
||||
method: PATCH
|
||||
path: '/${admin_path}'
|
||||
header:
|
||||
Content-Type: application/json-patch+json
|
||||
Prefer: return=representation
|
||||
content:
|
||||
-
|
||||
op: replace
|
||||
path: /role
|
||||
value: admin
|
||||
retain:
|
||||
admin: body
|
||||
conditions:
|
||||
is:
|
||||
code: 200
|
||||
'${admin}.is_system': 0
|
||||
'${admin}.is_superuser': 1
|
||||
'${admin}.is_ccare': 0
|
||||
'${admin}.lawful_intercept': 0
|
||||
|
||||
-
|
||||
name: delete admin
|
||||
type: item
|
||||
method: DELETE
|
||||
path: '/${admin_path}'
|
||||
conditions:
|
||||
is:
|
||||
code: 204
|
||||
Loading…
Reference in new issue