Skip to content

Commit 5aeaadc

Browse files
author
Jamie Hannaford
authored
Merge pull request #123 from samuel4x4/patch-1
Add support for creating policies
2 parents 474a064 + 4600b06 commit 5aeaadc

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

src/Identity/v3/Api.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,9 @@ public function getRoleAssignments(): array
770770
public function postPolicies(): array
771771
{
772772
return [
773-
'method' => 'POST',
774-
'path' => 'policies',
773+
'method' => 'POST',
774+
'path' => 'policies',
775+
'jsonKey' => 'policy',
775776
'params' => [
776777
'blob' => $this->params->blob(),
777778
'projectId' => $this->params->projectId('policy'),

src/Identity/v3/Models/Policy.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class Policy extends OperatorResource implements Creatable, Listable, Retrievabl
3232
/** @var string */
3333
public $userId;
3434

35+
protected $resourceKey = 'policy';
36+
protected $resourcesKey = 'policies';
37+
3538
protected $aliases = [
3639
'project_id' => 'projectId',
3740
'user_id' => 'userId'

tests/unit/Identity/v3/Models/PolicyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function test_it_creates()
3737
'user_id' => 'id',
3838
];
3939

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

4242
/** @var $policy \OpenStack\Identity\v3\Models\Policy */
4343
$policy = $this->policy->create($userOptions);

tests/unit/Identity/v3/ServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public function test_it_creates_policy()
435435
'user_id' => $userOptions['userId'],
436436
];
437437

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

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

0 commit comments

Comments
 (0)