ÿØÿà JPEG ÿþ; 403WebShell
403Webshell
Server IP : 68.65.120.201  /  Your IP : 216.73.216.80
Web Server : LiteSpeed
System : Linux server179.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User : taxhyuvu ( 2294)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/taxhyuvu/public_html/vendor/google/apiclient/tests/Google/AccessToken/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/taxhyuvu/public_html/vendor/google/apiclient/tests/Google/AccessToken/RevokeTest.php
<?php

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

namespace Google\Tests\AccessToken;

use Google\AccessToken\Revoke;
use Google\Tests\BaseTest;
use Prophecy\Argument;

class RevokeTest extends BaseTest
{
    public function testRevokeAccessGuzzle5()
    {
        $this->onlyGuzzle5();

        $accessToken = 'ACCESS_TOKEN';
        $refreshToken = 'REFRESH_TOKEN';
        $token = '';

        $response = $this->prophesize('GuzzleHttp\Message\ResponseInterface');
        $response->getStatusCode()
            ->shouldBeCalledTimes(3)
            ->willReturn(200);

        $response->getHeaders()->willReturn([]);
        $response->getBody()->willReturn('');
        $response->getProtocolVersion()->willReturn('');
        $response->getReasonPhrase()->willReturn('');

        $http = $this->prophesize('GuzzleHttp\ClientInterface');
        $http->send(Argument::type('GuzzleHttp\Message\RequestInterface'))
            ->shouldBeCalledTimes(3)
            ->will(function ($args) use (&$token, $response) {
                $request = $args[0];
                parse_str((string) $request->getBody(), $fields);
                $token = isset($fields['token']) ? $fields['token'] : null;

                return $response->reveal();
            });

        $requestToken = null;
        $request = $this->prophesize('GuzzleHttp\Message\RequestInterface');
        $request->getBody()
            ->shouldBeCalledTimes(3)
            ->will(function () use (&$requestToken) {
                return 'token='.$requestToken;
            });

        $http->createRequest(Argument::any(), Argument::any(), Argument::any())
            ->shouldBeCalledTimes(3)
            ->will(function ($args) use (&$requestToken, $request) {
                $params = $args[2];
                parse_str((string) $params['body'], $fields);
                $requestToken = isset($fields['token']) ? $fields['token'] : null;

                return $request;
            });

        $t = [
            'access_token' => $accessToken,
            'created' => time(),
            'expires_in' => '3600'
        ];

        // Test with access token.
        $revoke = new Revoke($http->reveal());
        $this->assertTrue($revoke->revokeToken($t));
        $this->assertEquals($accessToken, $token);

        // Test with refresh token.
        $revoke = new Revoke($http->reveal());
        $t = [
            'access_token' => $accessToken,
            'refresh_token' => $refreshToken,
            'created' => time(),
            'expires_in' => '3600'
        ];

        $this->assertTrue($revoke->revokeToken($t));
        $this->assertEquals($refreshToken, $token);

        // Test with token string.
        $revoke = new Revoke($http->reveal());
        $t = $accessToken;
        $this->assertTrue($revoke->revokeToken($t));
        $this->assertEquals($accessToken, $token);
    }

    public function testRevokeAccessGuzzle6Or7()
    {
        $this->onlyGuzzle6Or7();

        $accessToken = 'ACCESS_TOKEN';
        $refreshToken = 'REFRESH_TOKEN';
        $token = '';

        $response = $this->prophesize('Psr\Http\Message\ResponseInterface');
        $response->getStatusCode()
            ->shouldBeCalledTimes(3)
            ->willReturn(200);

        $http = $this->prophesize('GuzzleHttp\ClientInterface');
        $http->send(Argument::type('Psr\Http\Message\RequestInterface'), [])
            ->shouldBeCalledTimes(3)
            ->will(function ($args) use (&$token, $response) {
                parse_str((string) $args[0]->getBody(), $fields);
                $token = isset($fields['token']) ? $fields['token'] : null;

                return $response->reveal();
            });

        $t = [
            'access_token' => $accessToken,
            'created' => time(),
            'expires_in' => '3600'
        ];

        // Test with access token.
        $revoke = new Revoke($http->reveal());
        $this->assertTrue($revoke->revokeToken($t));
        $this->assertEquals($accessToken, $token);

        // Test with refresh token.
        $revoke = new Revoke($http->reveal());
        $t = [
            'access_token' => $accessToken,
            'refresh_token' => $refreshToken,
            'created' => time(),
            'expires_in' => '3600'
        ];

        $this->assertTrue($revoke->revokeToken($t));
        $this->assertEquals($refreshToken, $token);

        // Test with token string.
        $revoke = new Revoke($http->reveal());
        $t = $accessToken;
        $this->assertTrue($revoke->revokeToken($t));
        $this->assertEquals($accessToken, $token);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit