Skip to content

Commit

Permalink
Merge pull request #62 from silinternational/develop
Browse files Browse the repository at this point in the history
Add non-functioning twoStepVerification turnOff method placeholder
  • Loading branch information
mtompset authored Aug 16, 2023
2 parents 1ec0854 + 3a46bcb commit f09dd79
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 382 deletions.
3 changes: 3 additions & 0 deletions SilMock/Google/Service/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilMock\Google\Service\Directory\UsersResource;
use SilMock\Google\Service\Directory\UsersAliasesResource;
use SilMock\Google\Service\Directory\VerificationCodesResource;
use SilMock\Google\Service\Directory\Resource\TwoStepVerification;

class Directory
{
Expand All @@ -15,6 +16,7 @@ class Directory
public $users;
public $users_aliases;
public $verificationCodes;
public $twoStepVerification;

/**
* Sets the users and users_aliases properties to be instances of
Expand All @@ -30,5 +32,6 @@ public function __construct($client, $dbFile = null)
$this->users = new UsersResource($dbFile);
$this->users_aliases = new UsersAliasesResource($dbFile);
$this->verificationCodes = new VerificationCodesResource($dbFile);
$this->twoStepVerification = new TwoStepVerification($dbFile);
}
}
43 changes: 43 additions & 0 deletions SilMock/Google/Service/Directory/Resource/TwoStepVerification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace SilMock\Google\Service\Directory\Resource;

use SilMock\Google\Service\DbClass;

class TwoStepVerification extends dbClass
{
public function __construct(string $dbFile = '')
{
parent::__construct($dbFile, 'directory', 'twoStepVerification');
}

/**
* Turn off 2SV for a given email account.
*
* NOTE: This doesn't need to work. It just needs to exist.
*
* @param $userKey
* @param array $optParams
* @return void
*/
public function turnOff($userKey, $optParams = [])
{
// Grab the corresponding twoStepVerification record.
$sqliteUtils = $this->getSqliteUtils();
$twoStepVerificationRecord = $sqliteUtils->getAllRecordsByDataKey(
$this->dataType,
$this->dataClass,
'twoStepVerification',
$userKey
);
// Update it
$twoStepVerificationRecord['onOrOff'] = 'off';
// Get the record id and update it, as needed.
$recordId = $twoStepVerificationRecord['id'];
// If there was a recordId, then it probably would be functional
// However, we just need this method to exist, not actually work
if (! empty($recordId)) {
$sqliteUtils->updateRecordById($recordId, json_encode($twoStepVerificationRecord));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Service\Directory\Resource;

use Exception;
use PHPUnit\Framework\TestCase;
use SilMock\Google\Service\Directory\Resource\TwoStepVerification;

class TwoStepVerificationTest extends TestCase
{
public $dataFile = DATAFILE2;

public function testTwoStepVerificationTurnOff()
{
$twoStepVerfication = new TwoStepVerification($this->dataFile);
$this->assertIsObject($twoStepVerfication, 'Unable to instantiate twoStepVerification Mock object');

try {
$twoStepVerfication->turnOff('[email protected]');
} catch (Exception $exception) {
$this->assertFalse(
true,
sprintf(
'Was expecting the turnOff method to function, but got: %s',
$exception->getMessage()
)
);
}
}
}
Loading

0 comments on commit f09dd79

Please sign in to comment.