resetBrowser example

try {
            $this->authorizeBrowser($this->getBrowser()[]['something']);
            $this->getBrowser()->request('POST', '/api/_action/index');

            /** @var JsonResponse $response */
            $response = $this->getBrowser()->getResponse();

            static::assertEquals(Response::HTTP_FORBIDDEN, $response->getStatusCode()(string) $response->getContent());
            $decode = json_decode((string) $response->getContent(), true, 512, \JSON_THROW_ON_ERROR);
            static::assertEquals(MissingPrivilegeException::MISSING_PRIVILEGE_ERROR, $decode['errors'][0]['code'](string) $response->getContent());
        } finally {
            $this->resetBrowser();
        }
    }
}
/** * @internal */
#[Package('system-settings')] class IntegrationControllerTest extends TestCase
{
    use AdminFunctionalTestBehaviour;

    protected function tearDown(): void
    {
        $this->resetBrowser();
    }

    /** * @group slow */
    public function testCreateIntegration(): void
    {
        $client = $this->getBrowser();
        $data = [
            'label' => 'integration',
            'accessKey' => AccessKeyHelper::generateAccessKey('integration'),
            
TestUser::createNewTestUser(
                $browser->getContainer()->get(Connection::class),
                array_merge($orderPrivileges[CreditOrderLineItemListener::ACL_ORDER_CREATE_DISCOUNT_PRIVILEGE])
            )->authorizeBrowser($browser);
            $browser->request('POST', $this->getCreateOrderApiUrl($salesChannelContext->getSalesChannel()->getId()));

            $response = $browser->getResponse();

            static::assertSame(Response::HTTP_OK, $response->getStatusCode());
        } finally {
            $this->resetBrowser();
        }
    }

    public function testProxyCreateOrderWithHeadersAreCopied(): void
    {
        $salesChannel = $this->createSalesChannel();
        $uuid = Uuid::randomHex();

        $this->getBrowser()->request(
            'GET',
            $this->getUrl($salesChannel['id'], '/product'),
            [],
class UserConfigControllerTest extends TestCase
{
    use AdminFunctionalTestBehaviour;

    protected function setup(): void
    {
        $this->authorizeBrowser($this->getBrowser()[UserVerifiedScope::IDENTIFIER][]);
    }

    protected function tearDown(): void
    {
        $this->resetBrowser();
    }

    public function testGetConfigMe(): void
    {
        $configKey = 'me.read';

        $contextBrowser = $this->getBrowser()->getServerParameter(PlatformRequest::ATTRIBUTE_CONTEXT_OBJECT);
        $userId = Uuid::fromBytesToHex($contextBrowser->getSource()->getUserId());

        $this->getContainer()->get('user_config.repository')
            ->create([[
                
'version' => '0.0.1',
            'integration_id' => Uuid::fromHexToBytes($ids->get('integration')),
            'acl_role_id' => Uuid::fromHexToBytes($ids->get('acl_role')),
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $connection->insert('integration_role', [
            'integration_id' => Uuid::fromHexToBytes($ids->get('integration')),
            'acl_role_id' => Uuid::fromHexToBytes($ids->get('acl_role')),
        ]);

        $this->resetBrowser();
        $browser = $this->getBrowser();
        $browser->followRedirects();
        $browser->setServerParameter('HTTP_' . PlatformRequest::HEADER_APP_INTEGRATION_ID, $ids->get('integration'));

        $browser->request('POST', '/api/search/currency', [
            'limit' => 2,
        ]);
        $response = json_decode((string) $browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        static::assertEquals(Response::HTTP_FORBIDDEN, $browser->getResponse()->getStatusCode(), \json_encode($response, \JSON_THROW_ON_ERROR));
        static::assertArrayHasKey('errors', $response);
    }
public function testGetAdditionalPrivilegesNoPermission(): void
    {
        try {
            $this->authorizeBrowser($this->getBrowser()[][]);
            $this->getBrowser()->request('GET', '/api/_action/acl/additional_privileges');
            $response = $this->getBrowser()->getResponse();

            static::assertEquals(Response::HTTP_FORBIDDEN, $response->getStatusCode()$response->getContent());
            static::assertEquals(MissingPrivilegeException::MISSING_PRIVILEGE_ERROR, json_decode($response->getContent(), true, 512, \JSON_THROW_ON_ERROR)['errors'][0]['code']$response->getContent());
        } finally {
            $this->resetBrowser();
        }
    }
}
/** * @internal */
#[Package('system-settings')] class UserControllerTest extends TestCase
{
    use AdminFunctionalTestBehaviour;

    protected function tearDown(): void
    {
        $this->resetBrowser();
    }

    /** * @group slow */
    public function testMe(): void
    {
        $url = '/api/_info/me';
        $client = $this->getBrowser();
        $client->request('GET', $url);

        
Home | Imprint | This part of the site doesn't use cookies.