public function test_setSourceWithConstructor() { $db = new UsfVipDatabase(); $source = Utility::getNonPublicPropertyValue($db, "source"); // source variable is private $this->assertEquals('vip', $source); }
public function testSetsSourceWithConstructor() { $db = new UsfNamsDatabase(); $this->assertAttributeContains('nams', 'source', $db); $source = Utility::getNonPublicPropertyValue($db, "source"); // source variable is private $this->assertEquals('nams', $source); }
public function testCustomConfigConstructor() { $config = ['cas_host' => 'cas.example.edu', 'cas_port' => 443, 'cas_context' => '/cas', 'ca_cert_path' => 'none']; $casAuth = new UsfAuthCAS($config); // CAS info are private attributes $casHost = Utility::getNonPublicPropertyValue($casAuth, "_casHost"); $casPort = Utility::getNonPublicPropertyValue($casAuth, "_casPort"); $casContext = Utility::getNonPublicPropertyValue($casAuth, "_casContext"); $this->assertEquals('cas.example.edu', $casHost); $this->assertEquals('443', $casPort); $this->assertEquals('/cas', $casContext); }
public function testSingleEntitlement() { $tokenObject = new UsfAuthToken('abc123', 'http://localhost/tokenAuth/'); // Create a mock subscriber. $mock = new Mock([new Response(200, [], Stream::factory('{"sub": "johndoe", "name": "John Doe", "eduPersonEntitlement": "admin"}'))]); // Guzzle client is a private attribute $httpClient = Utility::getNonPublicPropertyValue($tokenObject, "_httpClient"); $httpClient->getEmitter()->attach($mock); Utility::setNonPublicPropertyValue($tokenObject, "_httpClient", $httpClient); // Send a good token $tokenObject->validateRequest('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huZG9lIiwibmFtZSI6IkpvaG4gRG9lIiwiZWR1UGVyc29uRW50aXRsZW1lbnQiOiJhZG1pbiIsImF0dHJpYnV0ZTEiOnRydWV9.WVtooRDdtlZljN0fhZazwBVyX7qfbu-fW1fsRDrM5Qw'); $this->assertTrue($tokenObject->isAuthorized('admin')); }