use OC\AppFramework\Middleware\Security\Exceptions\SecurityException;
use OC\AppFramework\Utility\ControllerMethodReflector;
+use OC\User\Session;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
-use OCP\IRequest;
-use OCP\IUserSession;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;
+use OCP\IRequest;
/**
* This middleware sets the correct CORS headers on a response if the
private $reflector;
/**
- * @var IUserSession
+ * @var Session
*/
private $session;
/**
* @param IRequest $request
* @param ControllerMethodReflector $reflector
- * @param IUserSession $session
+ * @param Session $session
*/
public function __construct(IRequest $request,
ControllerMethodReflector $reflector,
- IUserSession $session) {
+ Session $session) {
$this->request = $request;
$this->reflector = $reflector;
$this->session = $session;
$pass = $this->request->server['PHP_AUTH_PW'];
$this->session->logout();
- if(!$this->session->login($user, $pass)) {
+ if(!$this->session->logClientIn($user, $pass)) {
throw new SecurityException('CORS requires basic auth', Http::STATUS_UNAUTHORIZED);
}
}
use OC\AppFramework\Middleware\Security\CORSMiddleware;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OC\AppFramework\Middleware\Security\Exceptions\SecurityException;
-use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\Response;
protected function setUp() {
parent::setUp();
$this->reflector = new ControllerMethodReflector();
- $this->session = $this->getMock('\OCP\IUserSession');
+ $this->session = $this->getMockBuilder('\OC\User\Session')
+ ->disableOriginalConstructor()
+ ->getMock();
}
/**
$this->session->expects($this->never())
->method('logout');
$this->session->expects($this->never())
- ->method('login')
+ ->method('logClientIn')
->with($this->equalTo('user'), $this->equalTo('pass'))
->will($this->returnValue(true));
$this->reflector->reflect($this, __FUNCTION__);
$this->session->expects($this->once())
->method('logout');
$this->session->expects($this->once())
- ->method('login')
+ ->method('logClientIn')
->with($this->equalTo('user'), $this->equalTo('pass'))
->will($this->returnValue(true));
$this->reflector->reflect($this, __FUNCTION__);
$this->session->expects($this->once())
->method('logout');
$this->session->expects($this->once())
- ->method('login')
+ ->method('logClientIn')
->with($this->equalTo('user'), $this->equalTo('pass'))
->will($this->returnValue(false));
$this->reflector->reflect($this, __FUNCTION__);