Skip to content

Commit fa2ef83

Browse files
committed
Merge branch 'NFS-616-claim-session-id' into NFS-616-session-flow
2 parents 8516bcd + 809f7c0 commit fa2ef83

2 files changed

Lines changed: 136 additions & 137 deletions

File tree

test/PluginSessionTest.php

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*
88
* @category Authentication
99
* @copyright 2017-2019 Staffbase, GmbH.
10-
* @author Vitaliy Ivanov
11-
* @license http://www.apache.org/licenses/LICENSE-2.0
12-
* @link https://github.com/staffbase/plugins-sdk-php
10+
* @author Vitaliy Ivanov
11+
* @license http://www.apache.org/licenses/LICENSE-2.0
12+
* @link https://github.com/staffbase/plugins-sdk-php
1313
*/
1414
namespace Staffbase\plugins\test;
1515

@@ -38,7 +38,7 @@ class PluginSessionTest extends TestCase
3838
*/
3939
public function __construct() {
4040

41-
parent::__construct();
41+
parent::__construct();
4242
$rsa = new RSA();
4343
$keypair = $rsa->createKey();
4444

@@ -85,13 +85,13 @@ public function testConstructorWorksAsExpected() {
8585
->onlyMethods(array('openSession', 'closeSession'))
8686
->getMock();
8787

88-
$mock->expects($this->exactly(2))
89-
->method('openSession')
90-
->with($this->pluginId);
88+
$mock->expects($this->exactly(2))
89+
->method('openSession')
90+
->with($this->pluginId);
9191

9292
$reflectedClass = new ReflectionClass($this->classname);
9393
$constructor = $reflectedClass->getConstructor();
94-
$constructor->invoke($mock, $this->pluginId, $this->publicKey);
94+
$constructor->invoke($mock, $this->pluginId, $this->publicKey);
9595

9696
$this->setupEnvironment($this->pluginInstanceId, null, false);
9797

@@ -114,11 +114,11 @@ public function testConstructorRejectsSpoofedPID() {
114114

115115
$this->setupEnvironment($this->pluginInstanceId. 'spoof', null, false);
116116

117-
$this->expectException(SSOException::class);
117+
$this->expectException(SSOException::class);
118118

119-
$reflectedClass = new ReflectionClass($this->classname);
120-
$constructor = $reflectedClass->getConstructor();
121-
$constructor->invoke($mock, $this->pluginId, $this->publicKey);
119+
$reflectedClass = new ReflectionClass($this->classname);
120+
$constructor = $reflectedClass->getConstructor();
121+
$constructor->invoke($mock, $this->pluginId, $this->publicKey);
122122
}
123123

124124
/**
@@ -137,12 +137,12 @@ public function testConstructorRefuseEmptyPluginId() {
137137
->onlyMethods(array('openSession', 'closeSession'))
138138
->getMock();
139139

140-
$this->expectException(SSOException::class);
141-
$this->expectExceptionMessage('Empty plugin ID.');
140+
$this->expectException(SSOException::class);
141+
$this->expectExceptionMessage('Empty plugin ID.');
142142

143-
$reflectedClass = new ReflectionClass($this->classname);
144-
$constructor = $reflectedClass->getConstructor();
145-
$constructor->invoke($mock, '', $this->publicKey);
143+
$reflectedClass = new ReflectionClass($this->classname);
144+
$constructor = $reflectedClass->getConstructor();
145+
$constructor->invoke($mock, '', $this->publicKey);
146146
}
147147

148148
/**
@@ -161,12 +161,12 @@ public function testConstructorRefuseEmptySecret() {
161161
->onlyMethods(array('openSession', 'closeSession'))
162162
->getMock();
163163

164-
$this->expectException(SSOException::class);
165-
$this->expectExceptionMessage('Empty app secret.');
164+
$this->expectException(SSOException::class);
165+
$this->expectExceptionMessage('Empty app secret.');
166166

167-
$reflectedClass = new ReflectionClass($this->classname);
168-
$constructor = $reflectedClass->getConstructor();
169-
$constructor->invoke($mock, $this->pluginId, '');
167+
$reflectedClass = new ReflectionClass($this->classname);
168+
$constructor = $reflectedClass->getConstructor();
169+
$constructor->invoke($mock, $this->pluginId, '');
170170
}
171171

172172
/**
@@ -185,12 +185,12 @@ public function testConstructorRefuseEmptyEnv() {
185185
->onlyMethods(array('openSession', 'closeSession'))
186186
->getMock();
187187

188-
$this->expectException(SSOAuthenticationException::class);
189-
$this->expectExceptionMessage('Missing PID or JWT query parameter in Request.');
188+
$this->expectException(SSOAuthenticationException::class);
189+
$this->expectExceptionMessage('Missing PID or JWT query parameter in Request.');
190190

191-
$reflectedClass = new ReflectionClass($this->classname);
192-
$constructor = $reflectedClass->getConstructor();
193-
$constructor->invoke($mock, $this->pluginId, $this->publicKey);
191+
$reflectedClass = new ReflectionClass($this->classname);
192+
$constructor = $reflectedClass->getConstructor();
193+
$constructor->invoke($mock, $this->pluginId, $this->publicKey);
194194
}
195195

196196
/**
@@ -209,12 +209,12 @@ public function testConstructorRefuseHavingBothJwtAndPid() {
209209
->onlyMethods(array('openSession', 'closeSession'))
210210
->getMock();
211211

212-
$this->expectException(SSOAuthenticationException::class);
213-
$this->expectExceptionMessage('Tried to initialize the session with both PID and JWT provided.');
212+
$this->expectException(SSOAuthenticationException::class);
213+
$this->expectExceptionMessage('Tried to initialize the session with both PID and JWT provided.');
214214

215-
$reflectedClass = new ReflectionClass($this->classname);
216-
$constructor = $reflectedClass->getConstructor();
217-
$constructor->invoke($mock, $this->pluginId, $this->publicKey);
215+
$reflectedClass = new ReflectionClass($this->classname);
216+
$constructor = $reflectedClass->getConstructor();
217+
$constructor->invoke($mock, $this->pluginId, $this->publicKey);
218218
}
219219

220220
/**
@@ -233,8 +233,8 @@ public function testConstructorUpdatesInfoOnJwt() {
233233
->onlyMethods(array('openSession', 'closeSession'))
234234
->getMock();
235235

236-
/** @var PluginSession $session */
237-
$session = new $mock($this->pluginId, $this->publicKey);
236+
/** @var PluginSession $session */
237+
$session = new $mock($this->pluginId, $this->publicKey);
238238

239239
$this->assertEquals($session->getRole(), $this->tokenData[PluginSession::CLAIM_USER_ROLE]);
240240

@@ -244,10 +244,9 @@ public function testConstructorUpdatesInfoOnJwt() {
244244

245245
$this->setupEnvironment(null, $newToken, false);
246246

247-
/** @var PluginSession $newSession */
248-
$newSession = new $mock($this->pluginId, $this->publicKey);
247+
/** @var PluginSession $newSession */
248+
$newSession = new $mock($this->pluginId, $this->publicKey);
249249

250-
/** @var PluginSession $newSession */
251250
$this->assertEquals($newSession->getRole(), $tokenData[PluginSession::CLAIM_USER_ROLE]);
252251
$this->assertEquals($session->getRole(), $newSession->getRole());
253252
}
@@ -270,8 +269,8 @@ public function testConstructorSupportMultipleInstances() {
270269
->onlyMethods(array('openSession', 'closeSession'))
271270
->getMock();
272271

273-
/** @var PluginSession $session */
274-
$session = new $mock($this->pluginId, $this->publicKey);
272+
/** @var PluginSession $session */
273+
$session = new $mock($this->pluginId, $this->publicKey);
275274

276275

277276
$tokenData = $this->tokenData;
@@ -281,14 +280,14 @@ public function testConstructorSupportMultipleInstances() {
281280

282281
$this->setupEnvironment(null, $newToken, false);
283282

284-
/** @var PluginSession $newSession */
285-
$newSession = new $mock($this->pluginId, $this->publicKey);
283+
/** @var PluginSession $newSession */
284+
$newSession = new $mock($this->pluginId, $this->publicKey);
286285

287286
$this->assertEquals($newSession->getRole(), $tokenData[PluginSession::CLAIM_USER_ROLE]);
288287
$this->assertNotEquals($session->getRole(), $newSession->getRole());
289288

290-
$sessionVar = 'myvariable';
291-
$sessionVal = 'mysessiontestvalue';
289+
$sessionVar = 'myvariable';
290+
$sessionVal = 'mysessiontestvalue';
292291
$sessionVal2 = 'mysessiontestvalue2';
293292

294293
$session->setSessionVar($sessionVar, $sessionVal);
@@ -316,8 +315,8 @@ public function testGetSessionData() {
316315
->onlyMethods(array('openSession', 'closeSession'))
317316
->getMock();
318317

319-
/** @var PluginSession $session */
320-
$session = new $mock($this->pluginId, $this->publicKey);
318+
/** @var PluginSession $session */
319+
$session = new $mock($this->pluginId, $this->publicKey);
321320

322321
$sessionData = [
323322
'test1' => 'val1',

0 commit comments

Comments
 (0)