getAccessKey example

static::assertEquals(2, $this->getRequestCount());

        $confirmationReq = $this->getPastRequest(1);
        static::assertEquals('POST', $confirmationReq->getMethod());

        $postBody = \json_decode($confirmationReq->getBody()->getContents(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertEquals($secretAccessKey$postBody['secretKey']);

        $integration = $app->getIntegration();
        static::assertNotNull($integration);
        static::assertEquals($integration->getAccessKey()$postBody['apiKey']);

        static::assertEquals($_SERVER['APP_URL']$postBody['shopUrl']);
        static::assertEquals($this->shopIdProvider->getShopId()$postBody['shopId']);

        $json = \json_encode($postBody, \JSON_THROW_ON_ERROR);
        static::assertNotFalse($json);

        static::assertEquals(
            \hash_hmac('sha256', $json$appSecret),
            $confirmationReq->getHeaderLine('shopware-shop-signature')
        );

        
$app->getName(),
                'The app url changed. Please resolve how the apps should handle this change.'
            );
        }

        // We can safely assume that the app has an integration because it is created together with the app         // and explicitly fetched in the ::getApp() method below.         /** @var IntegrationEntity $integration */
        $integration = $app->getIntegration();

        return [
            'apiKey' => $integration->getAccessKey(),
            'secretKey' => $secretAccessKey,
            'timestamp' => (string) (new \DateTime())->getTimestamp(),
            'shopUrl' => $this->shopUrl,
            'shopId' => $shopId,
        ];
    }

    /** * @param array<string, string> $body */
    private function signPayload(array $body, string $secret): string
    {
$this->restoreRequestStack($this->requestStack, $requestStackBackup);
        }
    }

    private function setUpSalesChannelApiRequest(string $path, string $salesChannelId, Request $request, SalesChannelEntity $salesChannel): Request
    {
        $contextToken = $this->getContextToken($request);

        $server = array_merge($request->server->all()['REQUEST_URI' => '/store-api/' . $path]);
        $subrequest = $request->duplicate(null, null, [], null, null, $server);

        $subrequest->headers->set(PlatformRequest::HEADER_ACCESS_KEY, $salesChannel->getAccessKey());
        $subrequest->headers->set(PlatformRequest::HEADER_CONTEXT_TOKEN, $contextToken);
        $subrequest->attributes->set(PlatformRequest::ATTRIBUTE_OAUTH_CLIENT_ID, $salesChannel->getAccessKey());

        $this->requestContextResolver->handleSalesChannelContext(
            $subrequest,
            $salesChannelId,
            $contextToken
        );

        return $subrequest;
    }

    
'countries' => [['id' => $this->getValidCountryId()]],
            'customerGroupId' => TestDefaults::FALLBACK_CUSTOMER_GROUP,
        ]]$context);

        $criteria1 = new Criteria([$salesChannelId]);
        $criteria1->addAssociation('type');

        $salesChannel = $this->salesChannelRepository->search($criteria1$context)->get($salesChannelId);

        static::assertInstanceOf(SalesChannelEntity::class$salesChannel);
        static::assertEquals($name$salesChannel->getName());
        static::assertEquals($accessKey$salesChannel->getAccessKey());

        static::assertInstanceOf(SalesChannelTypeEntity::class$salesChannel->getType());
        static::assertEquals($cover$salesChannel->getType()->getCoverUrl());
        static::assertEquals($icon$salesChannel->getType()->getIconName());
        static::assertEquals($screenshots$salesChannel->getType()->getScreenshotUrls());
        static::assertEquals($typeName$salesChannel->getType()->getName());
        static::assertEquals($manufacturer$salesChannel->getType()->getManufacturer());
        static::assertEquals($description$salesChannel->getType()->getDescription());
        static::assertEquals($descriptionLong$salesChannel->getType()->getDescriptionLong());

        $criteria = new Criteria();
        
'snippetSetId' => $this->getSnippetSetIdForLocale('en-GB'),
                    'url' => 'http://example.com',
                ],
            ],
        ]);

        $productExport = $this->createCsvExport(
            ProductExportEntity::ENCODING_UTF8,
            $salesChannelId,
            $salesChannelDomainId
        );
        $client->request('GET', getenv('APP_URL') . sprintf('/store-api/product-export/%s/%s', $productExport->getAccessKey()$productExport->getFileName()));

        $csvRows = explode(\PHP_EOL, (string) $client->getResponse()->getContent());

        static::assertCount(4, $csvRows);
        static::assertEquals(ProductExportEntity::ENCODING_UTF8, $client->getResponse()->getCharset());
    }

    public function testUtf8CsvExportWithTheme(): void
    {
        if (!$this->getContainer()->has(ThemeService::class) || !$this->getContainer()->has('theme.repository')) {
            static::markTestSkipped('This test needs storefront to be installed.');
        }
$container = $this->getContainer();

        /** @var EntityRepository $salesChannelRepository */
        $salesChannelRepository = $container->get('sales_channel.repository');
        /** @var SalesChannelEntity $salesChannel */
        $salesChannel = $salesChannelRepository->search(
            (new Criteria())->addFilter(new EqualsFilter('typeId', Defaults::SALES_CHANNEL_TYPE_STOREFRONT)),
            Context::createDefaultContext()
        )->first();

        $header = 'HTTP_' . str_replace('-', '_', mb_strtoupper(PlatformRequest::HEADER_ACCESS_KEY));
        $browser->setServerParameter($header$salesChannel->getAccessKey());
        $browser->setServerParameter('test-sales-channel-id', $salesChannel->getId());

        $customerId = Uuid::randomHex();
        $this->createCustomerWithEmail($customerId, 'foo@foo.de', 'bar12345', $salesChannel);
        $browser->request(
            'POST',
            $_SERVER['APP_URL'] . '/account/login',
            [
                'username' => 'foo@foo.de',
                'password' => 'bar12345',
            ]
        );
Home | Imprint | This part of the site doesn't use cookies.