|
18 | 18 | use ReflectionClass; |
19 | 19 | use phpseclib\Crypt\RSA; |
20 | 20 | use PHPUnit\Framework\TestCase; |
21 | | -use SessionHandlerInterface; |
22 | 21 | use Staffbase\plugins\sdk\Exceptions\SSOAuthenticationException; |
23 | 22 | use Staffbase\plugins\sdk\Exceptions\SSOException; |
24 | 23 | use Staffbase\plugins\sdk\SSOData\SharedClaimsInterface; |
@@ -385,7 +384,9 @@ public function testDeleteSuccessfulCallInterface() |
385 | 384 | ->onlyMethods(['openSession', 'closeSession', 'exitRemoteCall']) |
386 | 385 | ->getMock(); |
387 | 386 |
|
388 | | - new $Session($this->pluginId, $this->publicKey, null, 0, $handler); |
| 387 | + $session = new $Session($this->pluginId, $this->publicKey, null, 0, $handler); |
| 388 | + $this->assertInstanceOf($this->classname, $session); |
| 389 | + |
389 | 390 | } |
390 | 391 |
|
391 | 392 | /** |
@@ -426,7 +427,9 @@ public function testDeleteFailedCallInterface() |
426 | 427 | ->onlyMethods(['openSession', 'closeSession', 'exitRemoteCall']) |
427 | 428 | ->getMock(); |
428 | 429 |
|
429 | | - new $Session($this->pluginId, $this->publicKey, null, 0, $handler); |
| 430 | + $session = new $Session($this->pluginId, $this->publicKey, null, 0, $handler); |
| 431 | + $this->assertInstanceOf($this->classname, $session); |
| 432 | + |
430 | 433 | } |
431 | 434 |
|
432 | 435 | /** |
@@ -469,84 +472,10 @@ public function testSessionIdCheck() |
469 | 472 | public function testDestroyOtherSession() |
470 | 473 | { |
471 | 474 | $this->markTestSkipped('must be revisited.'); |
472 | | - |
473 | | - $sessionHash = 'HOjLTR6+D5YIY0/waqJQp3Bg='; |
474 | | - $sessionId = 'HOjLTR6-D5YIY0-waqJQp3Bg-'; |
475 | | - |
476 | | - $tokenData = $this->tokenData; |
477 | | - $tokenData[SSODataClaimsInterface::CLAIM_SESSION_ID] = $sessionHash; |
478 | | - $token = SSOTokenGenerator::createSignedTokenFromData($this->privateKey, $tokenData); |
479 | | - |
480 | | - // successfull remote call handler mock |
481 | | - $handler = $this->getMockBuilder(SessionHandlerInterface::class) |
482 | | - ->setMethodsExcept() |
483 | | - ->getMock(); |
484 | | - |
485 | | - $handler->method('close')->willReturn(true); |
486 | | - $handler->method('destroy')->willReturn(true); |
487 | | - $handler->method('open')->willReturn(true); |
488 | | - $handler->method('write')->willReturn(true); |
489 | | - $handler->method('read')->willReturn($sessionId); |
490 | | - |
491 | | - $this->setupEnvironment(null, $token); |
492 | | - |
493 | | - /** @var SessionHandlerInterface $handler */ |
494 | | - new PluginSession($this->pluginId, $this->publicKey); |
495 | | - |
496 | | - $this->setupEnvironment(null, $this->token, false); |
497 | | - |
498 | | - /** @var PluginSession $session */ |
499 | | - $session = new PluginSession($this->pluginId, $this->publicKey, $handler); |
500 | | - |
501 | | - $handler->expects($this->once()) |
502 | | - ->method('destroy') |
503 | | - ->with($sessionId); |
504 | | - |
505 | | - $handler->expects($this->exactly(2)) |
506 | | - ->method('write') |
507 | | - ->with($this->logicalOr( |
508 | | - $this->equalTo($sessionId), |
509 | | - $this->equalTo($this->tokenData[SSODataClaimsInterface::CLAIM_SESSION_ID]), |
510 | | - )); |
511 | | - |
512 | | - $handler->expects($this->exactly(2)) |
513 | | - ->method('open'); |
514 | | - |
515 | | - $session->destroySession($sessionHash); |
516 | 475 | } |
517 | 476 |
|
518 | 477 | public function testDestroyOwnSession() |
519 | 478 | { |
520 | | - |
521 | 479 | $this->markTestSkipped('must be revisited.'); |
522 | | - $sessionId = $this->tokenData[SSODataClaimsInterface::CLAIM_SESSION_ID]; |
523 | | - $this->setupEnvironment(null, $this->token, false); |
524 | | - |
525 | | - // successfull remote call handler mock |
526 | | - $handler = $this->getMockBuilder(SessionHandlerInterface::class) |
527 | | - ->setMethodsExcept() |
528 | | - ->getMock(); |
529 | | - |
530 | | - $handler->method('close')->willReturn(true); |
531 | | - $handler->method('destroy')->willReturn(true); |
532 | | - $handler->method('open')->willReturn(true); |
533 | | - $handler->method('write')->willReturn(true); |
534 | | - $handler->method('read')->willReturn($sessionId); |
535 | | - |
536 | | - /** @var PluginSession $session */ |
537 | | - $session = new PluginSession($this->pluginId, $this->publicKey, $handler); |
538 | | - |
539 | | - $handler->expects($this->once()) |
540 | | - ->method('destroy') |
541 | | - ->with($sessionId); |
542 | | - |
543 | | - $handler->expects($this->once()) |
544 | | - ->method('write') |
545 | | - ->with($sessionId); |
546 | | - |
547 | | - $handler->expects($this->once()) |
548 | | - ->method('open'); |
549 | | - |
550 | | - $session->destroySession($sessionId); |
551 | 480 | } |
552 | 481 | } |
0 commit comments