我正在使用经过身份验证的用户来测试不使用产品环境中的shibboleth提供程序的登录页面。但是在运行测试时,我似乎获得了500 http状态。这是配置:


  security_test.yml


security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        test:
            memory:
                users:
                    admin: { password: adminpass, roles: ['ROLE_ADMIN'] }

    firewalls:
        secured_area:
            pattern:    ^/apps
            http_basic:
                realm: "Secured Area"
            provider: test





  ControllerTest.php


class GenerateResetcodeControllerTest extends WebTestCase {

    private $client = null;

    public function setUp()
    {
        $this->client = static::createClient();
    }

    /**
     * @group debug
     */
    public function testGenerateResetCodeAction()
    {

        $crawler = $this->client->request('GET', '/apps/resetcode', array(), array(), array(
            'PHP_AUTH_USER' => 'admin',
            'PHP_AUTH_PW'   => 'adminpass',
        ));
        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
    }
}





  app / logs / test.log


[2015-03-24 11:15:54] app.CRITICAL: SSL connect error [] []
[2015-03-24 11:15:54] request.CRITICAL: Uncaught PHP Exception Util\XMLApiCallerBundle\Call\XMLApiCallerException: "System Unavailable" at /var/www/src/AccountServicesBundl
e/Services/AccountServiceRest.php line 149 {"exception":"[object] (Util\\XMLApiCallerBundle\\Call\\XMLApiCallerException(code: -1): System Unavailable at /var/www/src/AccountServicesBundle/Services/AccountServiceRest.php:149)"} []


有什么办法可以绕过SSL?

最佳答案

我认为您不必绕过安全连接。尝试这个:

$crawler = $this->client->request('GET', '/apps/resetcode', array(), array(),
    array(
        'PHP_AUTH_USER' => 'admin',
        'PHP_AUTH_PW'   => 'adminpass',
        'HTTPS' => true
    )
);


要么

public function setUp()
{
    $this->client = static::createClient(array(), array('HTTPS' => true));
}


它应该发出HTTPS请求。如果您确实想绕过SSL,则可以为测试环境创建routing_test.yml并覆盖路由定义,但这取决于您强制实施https限制的方式。

关于php - Symfony 2功能测试:绕过SSL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29240161/

10-11 08:32