/** * @expectedException Exception * @expectedExceptionMessage You must login or provide a valid TGT */ public function testFailedLogout() { $client = new CasRestClient(); $client->setCasServer('https://example.org'); $client->setCredentials('user', 'secret'); // Create a mock subscriber and response. $mock = new MockHandler([new Response(200, [])]); $handler = HandlerStack::create($mock); // Add the mock subscriber to the client. $client->setGuzzleClient(new Client(['base_uri' => 'https://example.org', 'handler' => $handler])); $this->assertTrue($client->logout()); }
<?php use epierce\CasRestClient; require_once 'vendor/autoload.php'; $client = new CasRestClient(); // Configure CAS client $client->setCasServer('https://cas.exmaple.edu'); $client->setCasRestContext('/v1/tickets'); $client->setCredentials("username", "password"); // Login and save TGT to a file $client->login('/tmp/cas_tgt.json'); // Make a webservice call $response = $client->get("https://someservice"); print_r(json_decode($response->getBody(), true)); // Make another call using the same SSO session $headers = ['User-Agent' => 'testing/1.0']; $post_params = ['param1' => 'foo', param2 => 'bar']; $response = $client->post("https://someotherservice", $headers, '', $post_params); print_r(json_decode($response->getBody(), true)); $client->logout();