Skip to content

Commit

Permalink
adding user quota using graph api instead of Provisioning api
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Panta committed Aug 9, 2023
1 parent db098fa commit 53fe2b7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
48 changes: 23 additions & 25 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ trait Provisioning {
* key is the lowercase username, value is an array of user attributes
*/
private array $createdUsers = [];
private FeatureContext $featureContext;

public SpacesContext $spacesContext;

/**
* list of users that were created on the remote server during test runs
Expand Down Expand Up @@ -5156,54 +5159,49 @@ public function theFollowingUsersShouldBeEnabled(TableNode $table):void {
}

/**
* @When the administrator sets the quota of user :user to :quota using the provisioning API
* @When the administrator sets the quota of user :user to :quota
*
* @param string $user
* @param string $quota
* @param int $quota
*
* @return void
*/
public function adminSetsUserQuotaToUsingTheProvisioningApi(string $user, string $quota):void {
$user = $this->getActualUsername($user);
$body
= [
'key' => 'quota',
'value' => $quota,
];

$this->response = OcsApiHelper::sendRequest(
$this->getBaseUrl(),
$this->getAdminUsername(),
$this->getAdminPassword(),
"PUT",
"/cloud/users/$user",
$this->getStepLineRef(),
$body
public function adminSetsUserQuotaToUsingTheGraphApi(string $user, int $quota):void {
$adminUser = $this->getAdminUsername();
$bodyData = ["quota" => ["total" => $quota]];
$spaceId = $this->spacesContext->getSpaceIdByName($user, "Personal");
$body = json_encode($bodyData, JSON_THROW_ON_ERROR);
$this->response = \TestHelpers\GraphHelper::updateSpace(
$this->getBaseUrl(),
$adminUser,
$this->getAdminPassword(),
$body,
$spaceId
);
}

/**
* @Given the quota of user :user has been set to :quota
*
* @param string $user
* @param string $quota
* @param int $quota
*
* @return void
*/
public function theQuotaOfUserHasBeenSetTo(string $user, string $quota):void {
$this->adminSetsUserQuotaToUsingTheProvisioningApi($user, $quota);
public function theQuotaOfUserHasBeenSetTo(string $user, int $quota):void {
$this->adminSetsUserQuotaToUsingTheGraphApi($user, $quota);
$this->theHTTPStatusCodeShouldBe(200);
}

/**
* @When the administrator gives unlimited quota to user :user using the provisioning API
* @When the administrator gives unlimited quota to user :user
*
* @param string $user
*
* @return void
*/
public function adminGivesUnlimitedQuotaToUserUsingTheProvisioningApi(string $user):void {
$this->adminSetsUserQuotaToUsingTheProvisioningApi($user, 'none');
public function adminGivesUnlimitedQuotaToUserUsingTheGraphApi(string $user):void {
$this->adminSetsUserQuotaToUsingTheGraphApi($user, 0);
}

/**
Expand All @@ -5214,7 +5212,7 @@ public function adminGivesUnlimitedQuotaToUserUsingTheProvisioningApi(string $us
* @return void
*/
public function userHasBeenGivenUnlimitedQuota(string $user):void {
$this->theQuotaOfUserHasBeenSetTo($user, 'none');
$this->theQuotaOfUserHasBeenSetTo($user, 0);
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ public function updateSpace(
} else {
$space = $this->getSpaceByName(($owner !== "") ? $owner : $user, $spaceName);
$spaceId = $space["id"];
var_dump("This is space name".$space);
}

$body = json_encode($bodyData, JSON_THROW_ON_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ public function asUserFolderShouldContainAPropertyWithValueOrWithValue(
[$property]
)
);

$this->theSingleResponseShouldContainAPropertyWithValueAndAlternative(
$property,
$expectedValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Feature: get quota

Scenario Outline: retrieving folder quota when no quota is set
Given using <dav-path-version> DAV path
When the administrator gives unlimited quota to user "Alice" using the provisioning API
When the administrator gives unlimited quota to user "Alice"
Then the HTTP status code should be "200"
And as user "Alice" folder "/" should contain a property "d:quota-available-bytes" with value "-3"
And as user "Alice" folder "/" should contain a property "d:quota-available-bytes" with value "0"
Examples:
| dav-path-version |
| old |
Expand All @@ -23,9 +23,9 @@ Feature: get quota
@smokeTest
Scenario Outline: retrieving folder quota when quota is set
Given using <dav-path-version> DAV path
When the administrator sets the quota of user "Alice" to "10 MB" using the provisioning API
When the administrator sets the quota of user "Alice" to 10000000
Then the HTTP status code should be "200"
And as user "Alice" folder "/" should contain a property "d:quota-available-bytes" with value "10485406"
And as user "Alice" folder "/" should contain a property "d:quota-available-bytes" with value "10000000"
Examples:
| dav-path-version |
| old |
Expand All @@ -37,7 +37,7 @@ Feature: get quota
Given using <dav-path-version> DAV path
And user "Brian" has been created with default attributes and small skeleton files
And user "Alice" has been given unlimited quota
And the quota of user "Brian" has been set to "10 MB"
And the quota of user "Brian" has been set to 10000000
And user "Brian" has created folder "/testquota"
And user "Brian" has created a share with settings
| path | testquota |
Expand All @@ -48,7 +48,7 @@ Feature: get quota
| propertyName |
| d:quota-available-bytes |
Then the HTTP status code should be "200"
And the single response should contain a property "d:quota-available-bytes" with value "10485406"
And the single response should contain a property "d:quota-available-bytes" with value "10000000"
Examples:
| dav-path-version |
| old |
Expand Down

0 comments on commit 53fe2b7

Please sign in to comment.