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