getBrowserAuthenticatedWithIntegration example

static::assertEquals(200, $this->getBrowser()->getResponse()->getStatusCode());
    }

    /** * NEXT-6026 * * @group quarantined */
    public function testDoesntAffectIntegrationWithoutApp(): void
    {
        $browser = $this->getBrowserAuthenticatedWithIntegration();
        $browser->request('GET', '/api/product');

        static::assertEquals(200, $browser->getResponse()->getStatusCode()(string) $browser->getResponse()->getContent());
    }

    private function fetchApp(string $appName): ?AppEntity
    {
        /** @var EntityRepository $appRepository */
        $appRepository = $this->getContainer()->get('app.repository');

        $criteria = new Criteria();
        


    protected function tearDown(): void
    {
        DisableRateLimiterCompilerPass::enableNoLimit();
    }

    public function testRateLimitNotificationRoute(): void
    {
        $ids = new IdsCollection();
        $integrationId = $ids->create('integration');
        $client = $this->getBrowserAuthenticatedWithIntegration($integrationId);

        $this->createApp($integrationId);
        $url = '/api/notification';
        $data = [
            'status' => 'success',
            'message' => 'This is a notification',
        ];

        for ($i = 0; $i <= 10; ++$i) {
            $client->request('POST', $url[][][](string) json_encode($data));

            
string $client,
        string $status,
        string $message,
        bool $adminOnly,
        array $requirePrivileges,
        bool $isSuccess
    ): void {
        $integrationId = null;
        if ($client === 'integration') {
            $ids = new IdsCollection();
            $integrationId = $ids->create('integration');
            $client = $this->getBrowserAuthenticatedWithIntegration($integrationId);
        } else {
            $client = $this->getBrowser();
        }

        $url = '/api/notification';
        $data = [
            'status' => $status,
            'message' => $message,
            'adminOnly' => $adminOnly,
            'requiredPrivileges' => $requirePrivileges,
        ];

        
'id' => $id,
            'productNumber' => Uuid::randomHex(),
            'stock' => 1,
            'name' => $id,
            'tax' => ['name' => 'test', 'taxRate' => 10],
            'manufacturer' => ['name' => 'test'],
            'price' => [
                ['currencyId' => Defaults::CURRENCY, 'gross' => 50, 'net' => 25, 'linked' => false],
            ],
        ];

        $this->getBrowserAuthenticatedWithIntegration()->request('POST', '/api/product', [][][]json_encode($data, \JSON_THROW_ON_ERROR));
        $response = $this->getBrowserAuthenticatedWithIntegration()->getResponse();

        static::assertSame(Response::HTTP_NO_CONTENT, $response->getStatusCode()(string) $response->getContent());

        static::assertNotEmpty($response->headers->get('Location'));
        static::assertEquals('http://localhost/api/product/' . $id$response->headers->get('Location'));

        $this->getBrowserAuthenticatedWithIntegration()->request('GET', '/api/product/' . $id);
        static::assertSame(Response::HTTP_OK, $this->getBrowserAuthenticatedWithIntegration()->getResponse()->getStatusCode()(string) $this->getBrowserAuthenticatedWithIntegration()->getResponse()->getContent());
    }

    
'product:delete' => false,
                ],
                [],
                false,
            ],
        ];
    }

    public function testAdminIntegration(): void
    {
        $ids = new IdsCollection();
        $browser = $this->getBrowserAuthenticatedWithIntegration($ids->create('integration'));

        $this->getContainer()
            ->get(Connection::class)
            ->executeStatement('UPDATE `integration` SET `admin` = 1 WHERE id = :id', ['id' => Uuid::fromHexToBytes($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(200, $browser->getResponse()->getStatusCode());
        


    public function testAccessFromAppIntegrationIsAllowed(): void
    {
        $this->loadAppsFromDir(__DIR__ . '/_fixtures');

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('name', 'api-endpoint-cases'));
        /** @var AppEntity $app */
        $app = $this->getContainer()->get('app.repository')->search($criteria, Context::createDefaultContext())->first();

        $browser = $this->getBrowserAuthenticatedWithIntegration($app->getIntegrationId());
        $browser->request('POST', '/api/script/simple-script');
        static::assertNotFalse($browser->getResponse()->getContent());

        $response = \json_decode($browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertSame(Response::HTTP_OK, $browser->getResponse()->getStatusCode()print_r($response, true));
    }

    public function testRedirectResponse(): void
    {
        $this->loadAppsFromDir(__DIR__ . '/_fixtures');

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