/** * Most of the logic for ID token validation is in AuthTest - * this is just a general check to ensure we verify a valid * id token if one exists. */ public function testValidateIdToken() { if (!$this->checkToken()) { return; } $client = $this->getClient(); $token = json_decode($client->getAccessToken()); $segments = explode(".", $token->id_token); $this->assertEquals(3, count($segments)); // Extract the client ID in this case as it wont be set on the test client. $data = json_decode(Postman_Google_Utils::urlSafeB64Decode($segments[1])); $oauth = new Postman_Google_Auth_OAuth2($client); $ticket = $oauth->verifyIdToken($token->id_token, $data->aud); $this->assertInstanceOf("Postman_Google_Auth_LoginTicket", $ticket); $this->assertTrue(strlen($ticket->getUserId()) > 0); // TODO(ianbarber): Need to be smart about testing/disabling the // caching for this test to make sense. Not sure how to do that // at the moment. $client = $this->getClient(); $client->setIo(new Postman_Google_IO_Stream($client)); $data = json_decode(Postman_Google_Utils::urlSafeB64Decode($segments[1])); $oauth = new Postman_Google_Auth_OAuth2($client); $this->assertInstanceOf("Postman_Google_Auth_LoginTicket", $oauth->verifyIdToken($token->id_token, $data->aud)); }