Skip to content

Commit

Permalink
Merge pull request #123 from samuel4x4/patch-1
Browse files Browse the repository at this point in the history
Add support for creating policies
  • Loading branch information
Jamie Hannaford committed Jun 13, 2017
2 parents 474a064 + 4600b06 commit 5aeaadc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Identity/v3/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,9 @@ public function getRoleAssignments(): array
public function postPolicies(): array
{
return [
'method' => 'POST',
'path' => 'policies',
'method' => 'POST',
'path' => 'policies',
'jsonKey' => 'policy',
'params' => [
'blob' => $this->params->blob(),
'projectId' => $this->params->projectId('policy'),
Expand Down
3 changes: 3 additions & 0 deletions src/Identity/v3/Models/Policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class Policy extends OperatorResource implements Creatable, Listable, Retrievabl
/** @var string */
public $userId;

protected $resourceKey = 'policy';
protected $resourcesKey = 'policies';

protected $aliases = [
'project_id' => 'projectId',
'user_id' => 'userId'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Identity/v3/Models/PolicyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function test_it_creates()
'user_id' => 'id',
];

$this->setupMock('POST', 'policies', $userJson, [], 'policy');
$this->setupMock('POST', 'policies', ['policy' => $userJson], [], 'policy');

/** @var $policy \OpenStack\Identity\v3\Models\Policy */
$policy = $this->policy->create($userOptions);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Identity/v3/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public function test_it_creates_policy()
'user_id' => $userOptions['userId'],
];

$this->setupMock('POST', 'policies', $userJson, [], 'policy');
$this->setupMock('POST', 'policies', ['policy' => $userJson], [], 'policy');

/** @var $endpoint \OpenStack\Identity\v3\Models\Policy */
$policy = $this->service->createPolicy($userOptions);
Expand Down

0 comments on commit 5aeaadc

Please sign in to comment.