From 082ad5ec62888a5f10c71e2f7e386edf0c8b3553 Mon Sep 17 00:00:00 2001 From: lukasmatusiewicz <77617779+lukasmatusiewicz@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:45:41 +0100 Subject: [PATCH] Delete EnrollTokenTest.php --- test/EnrollTokenTest.php | 157 --------------------------------------- 1 file changed, 157 deletions(-) delete mode 100644 test/EnrollTokenTest.php diff --git a/test/EnrollTokenTest.php b/test/EnrollTokenTest.php deleted file mode 100644 index 0fe0b65..0000000 --- a/test/EnrollTokenTest.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php - -//require_once(__DIR__ . '/../src/Client-Autoloader.php'); -require_once(__DIR__ . '/../vendor/autoload.php'); -require_once("utils/Utils.php"); - -use InterNations\Component\HttpMock\PHPUnit\HttpMockTrait; -use PHPUnit\Framework\TestCase; -use utils\Utils; - -class EnrollTokenTest extends TestCase implements PILog -{ - private $pi; - - use HttpMockTrait; - - public static function setUpBeforeClass(): void - { - static::setUpHttpMockBeforeClass('8082', 'localhost'); - } - - public static function tearDownAfterClass(): void - { - static::tearDownHttpMockAfterClass(); - } - - public function setUp(): void - { - $this->setUpHttpMock(); - $this->pi = new PrivacyIDEA('testUserAgent', "localhost:8082"); - $this->pi->realm = "testRealm"; - $this->pi->logger = $this; - } - - public function tearDown(): void - { - $this->tearDownHttpMock(); - } - - /** - * @throws PIBadRequestException - */ - public function testSuccess() - { - $responseBodyAuth = Utils::postAuthResponseBody(); - - $this->http->mock - ->when() - ->methodIs('POST') - ->pathIs('/auth') - ->then() - ->body($responseBodyAuth) - ->end(); - $this->http->setUp(); - - $this->http->mock - ->when() - ->methodIs('POST') - ->headerIs("Authorization", Utils::authToken()) - ->pathIs('/token/init') - ->then() - ->body(Utils::tokenInitResponseBody()) - ->end(); - $this->http->setUp(); - - $this->pi->serviceAccountName = "TestServiceAccount"; - $this->pi->serviceAccountPass = "TestServicePass"; - $this->pi->serviceAccountRealm = "TestServiceRealm"; - - $response = $this->pi->enrollToken( - "testUser", - "1", - "totp", - "Enrolled for test", - array('accept-language:en')); - - $this->assertNotNull($response); - $this->assertIsObject($response); - $this->assertObjectHasAttribute('detail', $response); - $this->assertEquals(Utils::imageData(), $response->detail->googleurl->img); - } - - /** - * @throws PIBadRequestException - */ - public function testNoServiceAccount() - { - $response = $this->pi->enrollToken( - "testUser", - "1", - "totp", - "Enrolled for test"); - - $this->assertNull($response); - } - - /** - * @throws PIBadRequestException - */ - public function testNoUsername() - { - $response = $this->pi->enrollToken( - "", - "1", - "totp", - "Enrolled for test"); - - $this->assertNull($response); - } - - /** - * @throws PIBadRequestException - */ - public function testUserAlreadyHasAToken() - { - $this->http->mock - ->when() - ->methodIs('POST') - ->pathIs('/auth') - ->then() - ->body(Utils::postAuthResponseBody()) - ->end(); - $this->http->setUp(); - - $this->http->mock - ->when() - ->methodIs('GET') - ->headerIs("Authorization", Utils::authToken()) - ->pathIs('/token') - ->then() - ->body(Utils::getTokenResponseBody()) - ->end(); - $this->http->setUp(); - - $this->pi->serviceAccountName = "TestServiceAccount"; - $this->pi->serviceAccountPass = "TestServicePass"; - $this->pi->serviceAccountRealm = "TestServiceRealm"; - - $response = $this->pi->enrollToken( - "testUser", - "1", - "totp", - "Enrolled for test"); - - $this->assertNull($response); - } - - public function piDebug($message) - { - echo $message . "\n"; - } - - public function piError($message) - { - echo "error: " . $message . "\n"; - } -} -- GitLab