Skip to content

Commit

Permalink
Merge pull request #60 from silinternational/develop
Browse files Browse the repository at this point in the history
Fix isEnrolled2Sv and isEnforced2Sv values
  • Loading branch information
mtompset authored Jul 27, 2023
2 parents 3f837bf + fdfbf00 commit 1ec0854
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions SilMock/Google/Service/Directory/UsersResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ public function insert($postBody)
'lastLoginTime' => $currentDateTime->format('c'),
'creationTime' => $currentDateTime->format('c'),
'agreedToTerms' => false,
'isEnforcedIn2Sv' => 'false',
'isEnrolledIn2Sv' => 'false',
);

// array_merge will not work, since $postBody is an object which only
Expand Down Expand Up @@ -202,7 +204,7 @@ public function insert($postBody)
$newAlias->kind = "personal";
$newAlias->primaryEmail = $postBody->primaryEmail;

$insertedAlias = $usersAliases->insertAssumingUserExists($newAlias);
$usersAliases->insertAssumingUserExists($newAlias);
}
}

Expand Down Expand Up @@ -240,6 +242,12 @@ public function update($userKey, $postBody)
$dbUserProps[$key] = $value;
}
}
if (!isset($dbUserProps['isEnforcedIn2Sv'])) {
$dbUserProps['isEnforcedIn2Sv'] = 'false';
}
if (!isset($dbUserProps['isEnrolledIn2Sv'])) {
$dbUserProps['isEnrolledIn2Sv'] = 'false';
}

// Delete the user's old aliases before adding the new ones
$usersAliases = new UsersAliasesResource($this->dbFile);
Expand Down Expand Up @@ -402,10 +410,11 @@ private function doesUserMatch($entry, $query = '')
}
if (! is_string($checkValue)) {
throw new \Exception(sprintf(
"Expecting a string.\nGot Entry: %s\nGot Field: %s\nGot VALUE: %s",
"Expecting a string.\nGot Entry: %s\nGot Field: %s\nGot VALUE: %s (%s)",
var_export($entry, true),
var_export($field, true),
var_export($checkValue, true)
var_export($checkValue, true),
gettype($checkValue)
));
}
if (mb_strpos($checkValue, $value) === 0) {
Expand Down

0 comments on commit 1ec0854

Please sign in to comment.