예제 #1
0
 public function testWithNonAuthenticatedProcessorAndMapRequiringAuthentication()
 {
     $o = new RESTController();
     $_SERVER['PHP_AUTH_USER'] = '******';
     $_SERVER['PHP_AUTH_PW'] = '123#';
     $_SERVER['CONTENT_TYPE'] = 'application/json';
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $m = new ProcessorMap(__FILE__, '.*');
     $m->setAuthenticationType(HttpAuthenticationA::BASIC);
     $p = new RESTProcessorA_underTest_getResponse();
     $p->validRequestMethods = [HttpRequestTypes::GET];
     $p->setMap($m);
     $r = $o->getResponse(new RESTRequest(), $p);
     $this->assertInstanceOf(HttpResponse::class, $r);
     $this->assertEquals(HttpResponseType::NOT_AUTHORIZED, $r->getStatus());
     $err = ['message' => 'This resource requires authentication but doesn\'t support any authorization scheme', 'error_code' => HttpResponseType::NOT_AUTHORIZED];
     $this->assertJsonStringEqualsJsonString(json_encode($err), $r->getOutput());
 }