+ {{ 'If you want to start fresh with a new setup in Analytics, keep these critical points in mind:' | trans }}
+
+
{{ form_start(resetAnalyticsForm) }}
{{ viewActionButton(app.request.headers.get('referer'), 'Cancel' | trans) }}
diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/quicksight-analytics-actions.twig b/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/quicksight-analytics-reset-action.twig
similarity index 100%
rename from src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/quicksight-analytics-actions.twig
rename to src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/quicksight-analytics-reset-action.twig
diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/quicksight-analytics.twig b/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/quicksight-analytics.twig
index 7c4205a..d4c2edb 100644
--- a/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/quicksight-analytics.twig
+++ b/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/quicksight-analytics.twig
@@ -13,36 +13,34 @@
{% endfor %}
{% endif %}
-{% if isAssetBundleSuccessfullyInitialized and not isAssetBundleInitializationInProgress %}
- {% if isQuicksightUserRoleAvailable %}
- {% if quicksightGenerateEmbedUrlResponse.errors | length %}
- {% for error in quicksightGenerateEmbedUrlResponse.errors %}
-
{{ error.message }}
- {% endfor %}
- {% endif %}
- {% if quicksightGenerateEmbedUrlResponse.embedUrl is not null and quicksightGenerateEmbedUrlResponse.embedUrl.url is not null %}
-
-
-
- {% endif %}
- {% else %}
-
- {{ 'No Analytics permission has been granted to the current user.' | trans }}
-
- {% endif %}
-{% elseif isAssetBundleInitializationInProgress %}
-
{{ 'Spryker Analytics is being activated. Please wait 4-5 minutes and reload the page.' | trans }}
-{% else %}
+{% if isEnableAnalyticsAllowed %}
-
{{ 'Spryker Analytics is not enabled yet' | trans }}
-
{{ 'You can enable Spryker Analytics to view and modify default dashboards with the ability to share them with other users. ' | trans }}
+
{{ 'Analytics is not enabled yet' | trans }}
+
{{ 'You can enable Analytics to view and modify dashboards with the ability to share them with other users. ' | trans }}
{{ viewActionButton(url('/amazon-quicksight/analytics/enable'), 'Enable Analytics' | trans) }}
+{% elseif isDisplayAnalyticsAllowed %}
+ {% if quicksightGenerateEmbedUrlResponse.errors | length %}
+ {% for error in quicksightGenerateEmbedUrlResponse.errors %}
+
{{ error.message }}
+ {% endfor %}
+ {% endif %}
+ {% if quicksightGenerateEmbedUrlResponse.embedUrl is not null and quicksightGenerateEmbedUrlResponse.embedUrl.url is not null %}
+
+
+
+ {% endif %}
+{% elseif isAssetBundleInitializationInProgress %}
+
{{ 'Analytics is being activated. Please wait 3-5 minutes and reload the page.' | trans }}
+{% else %}
+
+ {{ 'No Analytics permission has been granted to the current user.' | trans }}
+
{% endif %}
diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/synchronize-quicksight-users-action.twig b/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/synchronize-quicksight-users-action.twig
new file mode 100644
index 0000000..274a99d
--- /dev/null
+++ b/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/synchronize-quicksight-users-action.twig
@@ -0,0 +1,5 @@
+
+
diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/user-form-quicksight-user-role-field.twig b/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/user-form-quicksight-user-role-field.twig
deleted file mode 100644
index f3fc39d..0000000
--- a/src/SprykerEco/Zed/AmazonQuicksight/Presentation/_partials/user-form-quicksight-user-role-field.twig
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/CreateQuicksightUsersByUserCollectionResponseTest.php b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/CreateQuicksightUsersByUserCollectionResponseTest.php
deleted file mode 100644
index 9b089a7..0000000
--- a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/CreateQuicksightUsersByUserCollectionResponseTest.php
+++ /dev/null
@@ -1,293 +0,0 @@
-getMockBuilder(AmazonQuicksightToMessengerFacadeInterface::class)
- ->getMock();
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::FACADE_MESSENGER, $messengerFacadeMock);
- }
-
- /**
- * @return void
- */
- public function testShouldPersistQuicksightUserWhenUserSuccessfullyRegisteredInQuicksight(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUserWithNotPersistedQuicksightUserRole(static::QUICKSIGHT_USER_ROLE_READER);
-
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $this->tester->getAwsQuicksightClientMockWithSuccessfulResponse(
- $this->createRegisterUserSuccessfulResponse($userTransfer),
- 'registerUser',
- ),
- );
-
- $userCollectionResponseTransfer = (new UserCollectionResponseTransfer())->addUser($userTransfer);
-
- // Act
- $userCollectionResponseTransfer = $this->tester->getFacade()
- ->createQuicksightUsersByUserCollectionResponse($userCollectionResponseTransfer);
-
- // Assert
- $this->assertCount(0, $userCollectionResponseTransfer->getErrors());
- $this->assertCount(1, $userCollectionResponseTransfer->getUsers());
-
- $quicksightUserEntity = $this->tester->findQuicksightUserByIdUser($userTransfer->getIdUserOrFail());
- $this->assertNotNull($quicksightUserEntity);
-
- /** @var \Generated\Shared\Transfer\UserTransfer $userTransfer */
- $userTransfer = $userCollectionResponseTransfer->getUsers()->getIterator()->current();
- $this->assertNotNull($userTransfer->getQuicksightUser());
- $this->assertNotNull($userTransfer->getQuicksightUserOrFail()->getIdQuicksightUser());
- $this->assertNotNull($userTransfer->getQuicksightUserOrFail()->getArn());
- $this->assertNotNull($userTransfer->getQuicksightUserOrFail()->getPrincipalId());
- }
-
- /**
- * @return void
- */
- public function testShouldReturnErrorWhenQuicksightClientThrowsException(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUserWithNotPersistedQuicksightUserRole(static::QUICKSIGHT_USER_ROLE_READER);
-
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $this->tester->getAwsQuicksightClientMockWithErrorResponse(
- $this->tester->getQuicksightExceptionMock(static::ERROR_MESSAGE_QUICKSIGHT_USER_REGISTER_FAILURE),
- 'registerUser',
- ),
- );
-
- $userCollectionResponseTransfer = (new UserCollectionResponseTransfer())->addUser($userTransfer);
-
- // Act
- $userCollectionResponseTransfer = $this->tester->getFacade()
- ->createQuicksightUsersByUserCollectionResponse($userCollectionResponseTransfer);
-
- // Assert
- $this->assertCount(1, $userCollectionResponseTransfer->getErrors());
- $this->assertCount(1, $userCollectionResponseTransfer->getUsers());
-
- /** @var \Generated\Shared\Transfer\ErrorTransfer $errorTransfer */
- $errorTransfer = $userCollectionResponseTransfer->getErrors()->getIterator()->current();
- $this->assertSame(static::ERROR_MESSAGE_QUICKSIGHT_USER_REGISTER_FAILURE, $errorTransfer->getMessage());
- $this->assertSame((string)$userCollectionResponseTransfer->getUsers()->getIterator()->key(), $errorTransfer->getEntityIdentifier());
-
- /** @var \Generated\Shared\Transfer\UserTransfer $userTransfer */
- $userTransfer = $userCollectionResponseTransfer->getUsers()->getIterator()->current();
- $this->assertNotNull($userTransfer->getQuicksightUser());
- $this->assertNull($userTransfer->getQuicksightUserOrFail()->getIdQuicksightUser());
- $this->assertNull($userTransfer->getQuicksightUserOrFail()->getArn());
- $this->assertNull($userTransfer->getQuicksightUserOrFail()->getPrincipalId());
- }
-
- /**
- * @return void
- */
- public function testShouldReturnErrorWhenQuicksightUserRegisterResponseDoesNotContainUserKey(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUserWithNotPersistedQuicksightUserRole(static::QUICKSIGHT_USER_ROLE_READER);
-
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $this->tester->getAwsQuicksightClientMockWithSuccessfulResponse(new Result(), 'registerUser'),
- );
-
- $userCollectionResponseTransfer = (new UserCollectionResponseTransfer())->addUser($userTransfer);
-
- // Act
- $userCollectionResponseTransfer = $this->tester->getFacade()
- ->createQuicksightUsersByUserCollectionResponse($userCollectionResponseTransfer);
-
- // Assert
- $this->assertCount(1, $userCollectionResponseTransfer->getErrors());
- $this->assertCount(1, $userCollectionResponseTransfer->getUsers());
-
- /** @var \Generated\Shared\Transfer\ErrorTransfer $errorTransfer */
- $errorTransfer = $userCollectionResponseTransfer->getErrors()->getIterator()->current();
- $this->assertSame(static::ERROR_MESSAGE_USER_REGISTRATION_FAILED, $errorTransfer->getMessage());
- $this->assertSame((string)$userCollectionResponseTransfer->getUsers()->getIterator()->key(), $errorTransfer->getEntityIdentifier());
-
- /** @var \Generated\Shared\Transfer\UserTransfer $userTransfer */
- $userTransfer = $userCollectionResponseTransfer->getUsers()->getIterator()->current();
- $this->assertNotNull($userTransfer->getQuicksightUser());
- $this->assertNull($userTransfer->getQuicksightUserOrFail()->getIdQuicksightUser());
- $this->assertNull($userTransfer->getQuicksightUserOrFail()->getArn());
- $this->assertNull($userTransfer->getQuicksightUserOrFail()->getPrincipalId());
- }
-
- /**
- * @return void
- */
- public function testShouldDoNothingWhenQuicksightUserRoleIsNotProvidedForUser(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser();
-
- $awsQuicksightClientMock = $this->tester->getAwsQuicksightClientMock();
- $awsQuicksightClientMock->expects($this->never())->method('registerUser');
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $awsQuicksightClientMock,
- );
-
- // Act
- $userCollectionResponseTransfer = (new UserCollectionResponseTransfer())->addUser($userTransfer);
-
- // Act
- $userCollectionResponseTransfer = $this->tester->getFacade()
- ->createQuicksightUsersByUserCollectionResponse($userCollectionResponseTransfer);
-
- // Assert
- $this->assertCount(0, $userCollectionResponseTransfer->getErrors());
- $this->assertCount(1, $userCollectionResponseTransfer->getUsers());
- $this->assertNull($userCollectionResponseTransfer->getUsers()->getIterator()->current()->getQuicksightUser());
- }
-
- /**
- * @return void
- */
- public function testShouldDoNothingWhenQuicksightUserAlreadyExistsForProvidedForUser(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser();
- $this->tester->haveQuicksightUser($userTransfer);
-
- $awsQuicksightClientMock = $this->tester->getAwsQuicksightClientMock();
- $awsQuicksightClientMock->expects($this->never())->method('registerUser');
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $awsQuicksightClientMock,
- );
-
- // Act
- $userCollectionResponseTransfer = (new UserCollectionResponseTransfer())->addUser($userTransfer);
-
- // Act
- $userCollectionResponseTransfer = $this->tester->getFacade()
- ->createQuicksightUsersByUserCollectionResponse($userCollectionResponseTransfer);
-
- // Assert
- $this->assertCount(0, $userCollectionResponseTransfer->getErrors());
- $this->assertCount(1, $userCollectionResponseTransfer->getUsers());
- $this->assertNull($userCollectionResponseTransfer->getUsers()->getIterator()->current()->getQuicksightUser());
- }
-
- /**
- * @return void
- */
- public function testShouldDoNothingWhenQuicksightUserStatusIsNotApplicableForRegisteringQuicksightUser(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser([
- UserTransfer::STATUS => static::USER_STATUS_BLOCKED,
- ]);
-
- $awsQuicksightClientMock = $this->tester->getAwsQuicksightClientMock();
- $awsQuicksightClientMock->expects($this->never())->method('registerUser');
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $awsQuicksightClientMock,
- );
-
- // Act
- $userCollectionResponseTransfer = (new UserCollectionResponseTransfer())->addUser($userTransfer);
-
- // Act
- $userCollectionResponseTransfer = $this->tester->getFacade()
- ->createQuicksightUsersByUserCollectionResponse($userCollectionResponseTransfer);
-
- // Assert
- $this->assertCount(0, $userCollectionResponseTransfer->getErrors());
- $this->assertCount(1, $userCollectionResponseTransfer->getUsers());
- $this->assertNull($userCollectionResponseTransfer->getUsers()->getIterator()->current()->getQuicksightUser());
- }
-
- /**
- * @param \Generated\Shared\Transfer\UserTransfer $userTransfer
- *
- * @return \Aws\ResultInterface
- */
- protected function createRegisterUserSuccessfulResponse(UserTransfer $userTransfer): ResultInterface
- {
- $responseData = [
- 'RequestId' => time(),
- 'User' => [
- 'Arn' => 'arn:aws:quicksight:eu-central-1:123456789012:user/default/' . $userTransfer->getUsername(),
- 'PrincipalId' => '123456789012',
- 'Role' => $userTransfer->getQuicksightUserOrFail()->getRoleOrFail(),
- ],
- ];
-
- return new Result($responseData);
- }
-}
diff --git a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/DeleteNotMatchedQuicksightUsersTest.php b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/DeleteNotMatchedQuicksightUsersTest.php
deleted file mode 100644
index 5dfa401..0000000
--- a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/DeleteNotMatchedQuicksightUsersTest.php
+++ /dev/null
@@ -1,342 +0,0 @@
-tester->haveUser();
- $matchingQuicksightUserTransfer = (new QuicksightUserBuilder([
- QuicksightUserTransfer::USER_NAME => $userTransfer->getUsernameOrFail(),
- QuicksightUserTransfer::ROLE => static::QUICKSIGHT_USER_ROLE_READER,
- ]))->build();
- $notMatchingQuicksightUserTransfer = (new QuicksightUserBuilder([
- QuicksightUserTransfer::USER_NAME => 'non-existing-user@spryker.com',
- QuicksightUserTransfer::ROLE => static::QUICKSIGHT_USER_ROLE_READER,
- ]))->build();
-
- $quicksightClientMock = $this->tester->getAwsQuicksightClientMockWithSuccessfulResponse(
- $this->createListUsersSuccessfulResponse([
- $matchingQuicksightUserTransfer,
- $notMatchingQuicksightUserTransfer,
- ]),
- 'listUsers',
- );
- $quicksightClientMock->expects($this->once())
- ->method('deleteUserByPrincipalId')
- ->willReturn(new Result());
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT, $quicksightClientMock);
-
- // Act
- $quicksightUserCollectionResponseTransfer = $this->tester->getFacade()->deleteNotMatchedQuicksightUsers();
-
- // Assert
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getErrors());
- $this->assertCount(1, $quicksightUserCollectionResponseTransfer->getQuicksightUsers());
-
- $this->assertSame(
- $notMatchingQuicksightUserTransfer->getUserNameOrFail(),
- $quicksightUserCollectionResponseTransfer->getQuicksightUsers()->getIterator()->current()->getUserNameOrFail(),
- );
- }
-
- /**
- * @return void
- */
- public function testShouldDeleteRegisteredQuicksightUserWhenMatchedUserHasDeletedStatus(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser([UserTransfer::STATUS => static::USER_STATUS_DELETED]);
- $quicksightUserTransfer = (new QuicksightUserBuilder([
- QuicksightUserTransfer::USER_NAME => $userTransfer->getUsernameOrFail(),
- QuicksightUserTransfer::ROLE => static::QUICKSIGHT_USER_ROLE_READER,
- ]))->build();
-
- $quicksightClientMock = $this->tester->getAwsQuicksightClientMockWithSuccessfulResponse(
- $this->createListUsersSuccessfulResponse([$quicksightUserTransfer]),
- 'listUsers',
- );
- $quicksightClientMock->expects($this->once())
- ->method('deleteUserByPrincipalId')
- ->willReturn(new Result());
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT, $quicksightClientMock);
-
- // Act
- $quicksightUserCollectionResponseTransfer = $this->tester->getFacade()->deleteNotMatchedQuicksightUsers();
-
- // Assert
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getErrors());
- $this->assertCount(1, $quicksightUserCollectionResponseTransfer->getQuicksightUsers());
- $this->assertSame(
- $quicksightUserTransfer->getUserNameOrFail(),
- $quicksightUserCollectionResponseTransfer->getQuicksightUsers()->getIterator()->current()->getUserNameOrFail(),
- );
- }
-
- /**
- * @return void
- */
- public function testShouldDoNothingWhenEmptyUserListIsReturned(): void
- {
- // Arrange
- $this->tester->haveUser();
-
- $quicksightClientMock = $this->tester->getAwsQuicksightClientMockWithSuccessfulResponse(
- $this->createListUsersSuccessfulResponse([]),
- 'listUsers',
- );
- $quicksightClientMock->expects($this->never())
- ->method('deleteUserByPrincipalId')
- ->willReturn(new Result());
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT, $quicksightClientMock);
-
- // Act
- $quicksightUserCollectionResponseTransfer = $this->tester->getFacade()->deleteNotMatchedQuicksightUsers();
-
- // Assert
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getErrors());
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getQuicksightUsers());
- }
-
- /**
- * @return void
- */
- public function testShouldDoNothingWhenMatchedUserHavePersistedQuicksightUser(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser();
- $quicksightUserTransfer = $this->tester->haveQuicksightUser($userTransfer, [
- QuicksightUserTransfer::USER_NAME => $userTransfer->getUsernameOrFail(),
- QuicksightUserTransfer::ROLE => static::QUICKSIGHT_USER_ROLE_READER,
- ]);
-
- $quicksightClientMock = $this->tester->getAwsQuicksightClientMockWithSuccessfulResponse(
- $this->createListUsersSuccessfulResponse([$quicksightUserTransfer]),
- 'listUsers',
- );
- $quicksightClientMock->expects($this->never())
- ->method('deleteUserByPrincipalId')
- ->willReturn(new Result());
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT, $quicksightClientMock);
-
- // Act
- $quicksightUserCollectionResponseTransfer = $this->tester->getFacade()->deleteNotMatchedQuicksightUsers();
-
- // Assert
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getErrors());
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getQuicksightUsers());
- }
-
- /**
- * @return void
- */
- public function testShouldReturnEmptyCollectionWhenRegisteredQuicksightUserHasUnsupportedRole(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser();
- $quicksightUserTransfer = (new QuicksightUserBuilder([
- QuicksightUserTransfer::USER_NAME => 'non-existing-user@spryker.com',
- QuicksightUserTransfer::ROLE => static::QUICKSIGHT_USER_ROLE_ADMIN,
- ]))->build();
-
- $quicksightClientMock = $this->tester->getAwsQuicksightClientMockWithSuccessfulResponse(
- $this->createListUsersSuccessfulResponse([$quicksightUserTransfer]),
- 'listUsers',
- );
- $quicksightClientMock->expects($this->never())
- ->method('deleteUserByPrincipalId')
- ->willReturn(new Result());
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT, $quicksightClientMock);
-
- // Act
- $quicksightUserCollectionResponseTransfer = $this->tester->getFacade()->deleteNotMatchedQuicksightUsers();
-
- // Assert
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getErrors());
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getQuicksightUsers());
- }
-
- /**
- * @return void
- */
- public function testShouldReturnErrorWhenQuicksightClientMethodListUsersThrowsException(): void
- {
- // Arrange
- $this->tester->haveUser();
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $this->tester->getAwsQuicksightClientMockWithErrorResponse(
- $this->tester->getQuicksightExceptionMock(static::ERROR_MESSAGE_QUICKSIGHT_API_FAILURE),
- 'listUsers',
- ),
- );
-
- // Act
- $quicksightUserCollectionResponseTransfer = $this->tester->getFacade()->deleteNotMatchedQuicksightUsers();
-
- // Assert
- $this->assertCount(1, $quicksightUserCollectionResponseTransfer->getErrors());
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getQuicksightUsers());
-
- $this->assertSame(
- static::ERROR_MESSAGE_QUICKSIGHT_API_FAILURE,
- $quicksightUserCollectionResponseTransfer->getErrors()->getIterator()->current()->getMessage(),
- );
- }
-
- /**
- * @return void
- */
- public function testShouldReturnErrorWhenQuicksightClientMethodDeleteUserByPrincipalIdThrowsException(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser();
- $quicksightUserTransfer = (new QuicksightUserBuilder([
- QuicksightUserTransfer::USER_NAME => 'non-existing-user@spryker.com',
- QuicksightUserTransfer::ROLE => static::QUICKSIGHT_USER_ROLE_READER,
- ]))->build();
-
- $quicksightClientMock = $this->tester->getAwsQuicksightClientMockWithSuccessfulResponse(
- $this->createListUsersSuccessfulResponse([$quicksightUserTransfer]),
- 'listUsers',
- );
- $quicksightClientMock->method('deleteUserByPrincipalId')
- ->willThrowException($this->tester->getQuicksightExceptionMock(static::ERROR_MESSAGE_QUICKSIGHT_API_FAILURE));
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT, $quicksightClientMock);
-
- // Act
- $quicksightUserCollectionResponseTransfer = $this->tester->getFacade()->deleteNotMatchedQuicksightUsers();
-
- // Assert
- $this->assertCount(1, $quicksightUserCollectionResponseTransfer->getErrors());
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getQuicksightUsers());
-
- $this->assertSame(
- static::ERROR_MESSAGE_QUICKSIGHT_API_FAILURE,
- $quicksightUserCollectionResponseTransfer->getErrors()->getIterator()->current()->getMessage(),
- );
- }
-
- /**
- * @return void
- */
- public function testShouldReturnErrorWhenQuicksightListUsersResponseDoesNotContainUserListKey(): void
- {
- // Arrange
- $this->tester->haveUser();
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $this->tester->getAwsQuicksightClientMockWithSuccessfulResponse(
- new Result([]),
- 'listUsers',
- ),
- );
-
- // Act
- $quicksightUserCollectionResponseTransfer = $this->tester->getFacade()->deleteNotMatchedQuicksightUsers();
-
- // Assert
- $this->assertCount(1, $quicksightUserCollectionResponseTransfer->getErrors());
- $this->assertCount(0, $quicksightUserCollectionResponseTransfer->getQuicksightUsers());
-
- $this->assertSame(
- static::ERROR_MESSAGE_USERS_LIST_RETRIEVE_FAILED,
- $quicksightUserCollectionResponseTransfer->getErrors()->getIterator()->current()->getMessage(),
- );
- }
-
- /**
- * @param list<\Generated\Shared\Transfer\QuicksightUserTransfer> $quicksightUserTransfers
- *
- * @return \Aws\ResultInterface
- */
- protected function createListUsersSuccessfulResponse(array $quicksightUserTransfers): ResultInterface
- {
- $quicksightUserList = [];
- foreach ($quicksightUserTransfers as $quicksightUserTransfer) {
- $quicksightUserList[] = [
- 'Arn' => $quicksightUserTransfer->getArnOrFail(),
- 'PrincipalId' => $quicksightUserTransfer->getPrincipalIdOrFail(),
- 'UserName' => $quicksightUserTransfer->getUserNameOrFail(),
- 'Role' => $quicksightUserTransfer->getRoleOrFail(),
- ];
- }
-
- return new Result([
- static::RESPONSE_KEY_USER_LIST => $quicksightUserList,
- ]);
- }
-}
diff --git a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/EnableAnalyticsTest.php b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/EnableAnalyticsTest.php
index c0bc981..220e19e 100644
--- a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/EnableAnalyticsTest.php
+++ b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/EnableAnalyticsTest.php
@@ -14,11 +14,9 @@
use Generated\Shared\Transfer\QuicksightAssetBundleImportJobTransfer;
use Generated\Shared\Transfer\QuicksightUserTransfer;
use Generated\Shared\Transfer\UserTransfer;
-use Spryker\Shared\Kernel\Transfer\Exception\NullValueException;
use Spryker\Shared\Kernel\Transfer\Exception\RequiredTransferPropertyException;
use SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightDependencyProvider;
use SprykerEco\Zed\AmazonQuicksight\Dependency\External\AmazonQuicksightToAwsQuicksightClientInterface;
-use SprykerEco\Zed\AmazonQuicksight\Dependency\Facade\AmazonQuicksightToMessengerFacadeInterface;
use SprykerEcoTest\Zed\AmazonQuicksight\AmazonQuicksightBusinessTester;
class EnableAnalyticsTest extends Unit
@@ -63,11 +61,6 @@ class EnableAnalyticsTest extends Unit
*/
protected const ERROR_MESSAGE_TEST = 'test error message';
- /**
- * @var string
- */
- protected const USER_STATUS_ACTIVE = 'active';
-
/**
* @uses \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig::QUICKSIGHT_USER_ROLE_READER
*
@@ -126,42 +119,20 @@ public function testThrowsRequiredTransferPropertyExceptionWhenRequiredPropertie
$this->tester->getFacade()->enableAnalytics($enableQuicksightAnalyticsRequestTransfer);
}
- /**
- * @return void
- */
- public function testThrowsNullValueExceptionWhenRequiredPropertiesAreNotSet(): void
- {
- // Arrange
- $enableQuicksightAnalyticsRequestTransfer = (new EnableQuicksightAnalyticsRequestTransfer())
- ->setUser(new UserTransfer())
- ->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID);
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $this->tester->getAwsQuicksightClientMock(),
- );
-
- // Assert
- $this->expectException(NullValueException::class);
-
- // Act
- $this->tester->getFacade()->enableAnalytics($enableQuicksightAnalyticsRequestTransfer);
- }
-
/**
* @dataProvider returnsResponseWithErrorWhenValidationFailsDataProvider
*
* @param \Generated\Shared\Transfer\QuicksightAssetBundleImportJobTransfer $quicksightAssetBundleImportJobTransfer
+ * @param \Generated\Shared\Transfer\EnableQuicksightAnalyticsRequestTransfer $enableQuicksightAnalyticsRequestTransfer
*
* @return void
*/
public function testReturnsResponseWithErrorWhenValidationFails(
- QuicksightAssetBundleImportJobTransfer $quicksightAssetBundleImportJobTransfer
+ QuicksightAssetBundleImportJobTransfer $quicksightAssetBundleImportJobTransfer,
+ EnableQuicksightAnalyticsRequestTransfer $enableQuicksightAnalyticsRequestTransfer
): void {
// Arrange
$this->tester->haveQuicksightAssetBundleImportJob($quicksightAssetBundleImportJobTransfer->toArray());
- $enableQuicksightAnalyticsRequestTransfer = (new EnableQuicksightAnalyticsRequestTransfer())
- ->setUser(new UserTransfer())
- ->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID);
$this->tester->setDependency(
AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
$this->tester->getAwsQuicksightClientMock(),
@@ -180,69 +151,6 @@ public function testReturnsResponseWithErrorWhenValidationFails(
);
}
- /**
- * @return void
- */
- public function testReturnsResponseWithErrorWhenUserCreationFails(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser();
- $enableQuicksightAnalyticsRequestTransfer = (new EnableQuicksightAnalyticsRequestTransfer())
- ->setUser($userTransfer->setStatus(static::USER_STATUS_ACTIVE))
- ->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID);
- $messengerFacadeMock = $this
- ->getMockBuilder(AmazonQuicksightToMessengerFacadeInterface::class)
- ->getMock();
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::FACADE_MESSENGER, $messengerFacadeMock);
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $this->tester->getAwsQuicksightClientMockWithErrorResponse(
- $this->tester->getQuicksightExceptionMock(static::ERROR_MESSAGE_TEST),
- 'registerUser',
- ),
- );
-
- // Act
- $enableQuicksightAnalyticsResponseTransfer = $this->tester
- ->getFacade()
- ->enableAnalytics($enableQuicksightAnalyticsRequestTransfer);
-
- // Assert
- $this->assertCount(1, $enableQuicksightAnalyticsResponseTransfer->getErrors());
- $this->assertSame(
- static::ERROR_MESSAGE_TEST,
- $enableQuicksightAnalyticsResponseTransfer->getErrors()->getIterator()->current()->getMessage(),
- );
- }
-
- /**
- * @return void
- */
- public function testReturnsResponseWithErrorWhenUserUpdateFails(): void
- {
- // Arrange
- $enableQuicksightAnalyticsRequestTransfer = $this->createEnableQuicksightAnalyticsRequestTransferWithUser(static::QUICKSIGHT_USER_ROLE_READER);
- $this->tester->setDependency(
- AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT,
- $this->tester->getAwsQuicksightClientMockWithErrorResponse(
- $this->tester->getQuicksightExceptionMock(static::ERROR_MESSAGE_TEST),
- 'updateUser',
- ),
- );
-
- // Act
- $enableQuicksightAnalyticsResponseTransfer = $this->tester
- ->getFacade()
- ->enableAnalytics($enableQuicksightAnalyticsRequestTransfer);
-
- // Assert
- $this->assertCount(1, $enableQuicksightAnalyticsResponseTransfer->getErrors());
- $this->assertSame(
- static::ERROR_MESSAGE_TEST,
- $enableQuicksightAnalyticsResponseTransfer->getErrors()->getIterator()->current()->getMessage(),
- );
- }
-
/**
* @return void
*/
@@ -359,86 +267,6 @@ public function testResetsNotFinishedAssetBundleImportJob(): void
);
}
- /**
- * @return void
- */
- public function testCreatesNewQuicksightAuthorUser(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser();
- $enableQuicksightAnalyticsRequestTransfer = (new EnableQuicksightAnalyticsRequestTransfer())
- ->setUser($userTransfer->setStatus(static::USER_STATUS_ACTIVE))
- ->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID);
- $awsQuicksightClientMock = $this->getAwsQuicksightClientMockWithExpectation(new Result(), 'startAssetBundleImportJob');
- $principalId = '123456789012';
- $arn = 'arn:aws:quicksight:eu-central-1:123456789012:user/default/' . $userTransfer->getUsername();
- $awsQuicksightClientMock->expects($this->once())->method('registerUser')->willReturn(new Result([
- 'RequestId' => time(),
- 'User' => [
- 'Arn' => $arn,
- 'PrincipalId' => $principalId,
- 'Role' => static::QUICKSIGHT_USER_ROLE_AUTHOR,
- ],
- ]));
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT, $awsQuicksightClientMock);
-
- // Act
- $enableQuicksightAnalyticsResponseTransfer = $this->tester
- ->getFacadeWithMocks()
- ->enableAnalytics($enableQuicksightAnalyticsRequestTransfer);
-
- // Assert
- $quicksightUserEntity = $this->tester->findQuicksightUserByIdUser($userTransfer->getIdUserOrFail());
- $this->assertNotNull($quicksightUserEntity);
- $this->assertSame(static::QUICKSIGHT_USER_ROLE_AUTHOR, $quicksightUserEntity->getRole());
- $this->assertSame($principalId, $quicksightUserEntity->getPrincipalId());
- $this->assertSame($arn, $quicksightUserEntity->getArn());
- $this->assertCount(0, $enableQuicksightAnalyticsResponseTransfer->getErrors());
- $this->assertNotNull($this->tester->findQuicksightAssetBundleImportJobQueryByJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID));
- }
-
- /**
- * @return void
- */
- public function testUpdatesQuicksightReaderUserToAuthor(): void
- {
- // Arrange
- $userTransfer = $this->tester->haveUser();
- $userTransfer->setQuicksightUser($this->tester->haveQuicksightUser($userTransfer, [
- QuicksightUserTransfer::ROLE => static::QUICKSIGHT_USER_ROLE_READER,
- ]));
- $enableQuicksightAnalyticsRequestTransfer = (new EnableQuicksightAnalyticsRequestTransfer())
- ->setUser($userTransfer->setStatus(static::USER_STATUS_ACTIVE))
- ->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID);
-
- $awsQuicksightClientMock = $this->getAwsQuicksightClientMockWithExpectation(new Result(), 'startAssetBundleImportJob');
- $principalId = '123456789012';
- $arn = 'arn:aws:quicksight:eu-central-1:123456789012:user/default/' . $userTransfer->getUsername();
- $awsQuicksightClientMock->expects($this->once())->method('updateUser')->willReturn(new Result([
- 'RequestId' => time(),
- 'User' => [
- 'Arn' => $arn,
- 'PrincipalId' => $principalId,
- 'Role' => static::QUICKSIGHT_USER_ROLE_AUTHOR,
- ],
- ]));
- $this->tester->setDependency(AmazonQuicksightDependencyProvider::AWS_QUICKSIGHT_CLIENT, $awsQuicksightClientMock);
-
- // Act
- $enableQuicksightAnalyticsResponseTransfer = $this->tester
- ->getFacadeWithMocks()
- ->enableAnalytics($enableQuicksightAnalyticsRequestTransfer);
-
- // Assert
- $quicksightUserEntity = $this->tester->findQuicksightUserByIdUser($userTransfer->getIdUserOrFail());
- $this->assertNotNull($quicksightUserEntity);
- $this->assertSame(static::QUICKSIGHT_USER_ROLE_AUTHOR, $quicksightUserEntity->getRole());
- $this->assertSame($principalId, $quicksightUserEntity->getPrincipalId());
- $this->assertSame($arn, $quicksightUserEntity->getArn());
- $this->assertCount(0, $enableQuicksightAnalyticsResponseTransfer->getErrors());
- $this->assertNotNull($this->tester->findQuicksightAssetBundleImportJobQueryByJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID));
- }
-
/**
* @return array
>
*/
@@ -455,7 +283,7 @@ protected function throwsRequiredTransferPropertyExceptionWhenRequiredProperties
}
/**
- * @return array>
+ * @return array>
*/
protected function returnsResponseWithErrorWhenValidationFailsDataProvider(): array
{
@@ -465,12 +293,42 @@ protected function returnsResponseWithErrorWhenValidationFailsDataProvider(): ar
->setIsInitialized(true)
->setJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID)
->setStatus(static::ASSET_BUNDLE_IMPORT_JOB_STATUS_SUCCESSFUL),
+ (new EnableQuicksightAnalyticsRequestTransfer())
+ ->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID)
+ ->setUser((new UserTransfer())->setQuicksightUser(
+ (new QuicksightUserTransfer())->setRole(static::QUICKSIGHT_USER_ROLE_AUTHOR),
+ )),
],
'Asset bundle initialization is in progress' => [
(new QuicksightAssetBundleImportJobTransfer())
->setIsInitialized(false)
->setJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID)
->setStatus(static::ASSET_BUNDLE_IMPORT_JOB_STATUS_IN_PROGRESS),
+ (new EnableQuicksightAnalyticsRequestTransfer())
+ ->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID)
+ ->setUser((new UserTransfer())->setQuicksightUser(
+ (new QuicksightUserTransfer())->setRole(static::QUICKSIGHT_USER_ROLE_AUTHOR),
+ )),
+ ],
+ 'Quicksight user does not exist' => [
+ (new QuicksightAssetBundleImportJobTransfer())
+ ->setIsInitialized(false)
+ ->setJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID)
+ ->setStatus(static::ASSET_BUNDLE_IMPORT_JOB_STATUS_FAILED_ROLLBACK_COMPLETED),
+ (new EnableQuicksightAnalyticsRequestTransfer())
+ ->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID)
+ ->setUser(new UserTransfer()),
+ ],
+ 'Quicksight user is not Author' => [
+ (new QuicksightAssetBundleImportJobTransfer())
+ ->setIsInitialized(false)
+ ->setJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID)
+ ->setStatus(static::ASSET_BUNDLE_IMPORT_JOB_STATUS_FAILED_ROLLBACK_COMPLETED),
+ (new EnableQuicksightAnalyticsRequestTransfer())
+ ->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID)
+ ->setUser((new UserTransfer())->setQuicksightUser(
+ (new QuicksightUserTransfer())->setRole(static::QUICKSIGHT_USER_ROLE_READER),
+ )),
],
];
}
@@ -489,7 +347,7 @@ protected function createEnableQuicksightAnalyticsRequestTransferWithUser(
]));
return (new EnableQuicksightAnalyticsRequestTransfer())
- ->setUser($userTransfer->setStatus(static::USER_STATUS_ACTIVE))
+ ->setUser($userTransfer)
->setAssetBundleImportJobId(static::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID);
}
diff --git a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandAnalyticsCollectionWithQuicksightAnalyticsTest.php b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandAnalyticsCollectionWithQuicksightAnalyticsTest.php
index 5bd6ed7..f1b264e 100644
--- a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandAnalyticsCollectionWithQuicksightAnalyticsTest.php
+++ b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandAnalyticsCollectionWithQuicksightAnalyticsTest.php
@@ -73,11 +73,32 @@ class ExpandAnalyticsCollectionWithQuicksightAnalyticsTest extends Unit
protected const TEMPLATE_PATH_QUICKSIGHT_ANALYTICS = '@AmazonQuicksight/_partials/quicksight-analytics.twig';
/**
- * @uses \SprykerEco\Zed\AmazonQuicksight\Business\Expander\AnalyticsExpander::TEMPLATE_PATH_QUICKSIGHT_ANALYTICS_ACTIONS
+ * @uses \SprykerEco\Zed\AmazonQuicksight\Business\Expander\AnalyticsExpander::TEMPLATE_PATH_QUICKSIGHT_ANALYTICS_RESET_ACTION
*
* @var string
*/
- protected const TEMPLATE_PATH_QUICKSIGHT_ANALYTICS_ACTIONS = '@AmazonQuicksight/_partials/quicksight-analytics-actions.twig';
+ protected const TEMPLATE_PATH_QUICKSIGHT_ANALYTICS_RESET_ACTION = '@AmazonQuicksight/_partials/quicksight-analytics-reset-action.twig';
+
+ /**
+ * @uses \SprykerEco\Zed\AmazonQuicksight\Business\Expander\AnalyticsExpander::TEMPLATE_PATH_SYNCHRONIZE_QUICKSIGHT_USERS_ACTION
+ *
+ * @var string
+ */
+ protected const TEMPLATE_PATH_SYNCHRONIZE_QUICKSIGHT_USERS_ACTION = '@AmazonQuicksight/_partials/synchronize-quicksight-users-action.twig';
+
+ /**
+ * @uses \SprykerEco\Zed\AmazonQuicksight\Business\Expander\AnalyticsExpander::FORM_NAME_SYNCHRONIZE_QUICKSIGHT_USERS
+ *
+ * @var string
+ */
+ protected const FORM_NAME_SYNCHRONIZE_QUICKSIGHT_USERS = 'synchronizeQuicksightUsersForm';
+
+ /**
+ * @uses \SprykerEco\Zed\AmazonQuicksight\Business\Expander\AnalyticsExpander::FIELD_NAME_TOKEN
+ *
+ * @var string
+ */
+ protected const FIELD_NAME_TOKEN = '_token';
/**
* @uses \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig::DEFAULT_ASSET_BUNDLE_IMPORT_JOB_ID
@@ -195,16 +216,17 @@ public function testExpandsCollectionWhenQuicksightUserExistsWithoutRole(): void
* @dataProvider expandsCollectionWhenQuicksightUserExistsWithRoleDataProvider
*
* @param string $role
+ * @param bool $isEnableAnalyticsAllowed
*
* @return void
*/
- public function testExpandsCollectionWhenQuicksightUserExistsWithRole(string $role): void
+ public function testExpandsCollectionWhenQuicksightUserExistsWithRole(string $role, bool $isEnableAnalyticsAllowed): void
{
// Arrange
$this->tester->getContainer()->set(static::SERVICE_TWIG, $this->getTwigMock(
+ $isEnableAnalyticsAllowed,
false,
false,
- true,
new QuicksightGenerateEmbedUrlResponseTransfer(),
));
$analyticsRequestTransfer = $this->tester->haveAnalyticsRequestWithQuicksightUser($role);
@@ -228,6 +250,8 @@ public function testExpandsCollectionWhenQuicksightUserExistsWithRole(string $ro
* @param bool $isInitializedInitially
* @param bool $isInitializedAfterSync
* @param bool $isInitializationInProgress
+ * @param bool $isEnableAnalyticsAllowed
+ * @param bool $isDisplayAnalyticsAllowed
* @param string $jobStatusAfterSync
* @param \Generated\Shared\Transfer\QuicksightGenerateEmbedUrlResponseTransfer $quicksightGenerateEmbedUrlResponseTransfer
*
@@ -237,14 +261,16 @@ public function testExpandsCollectionWhenQuicksightAssetBundleImportJobIsInProgr
bool $isInitializedInitially,
bool $isInitializedAfterSync,
bool $isInitializationInProgress,
+ bool $isEnableAnalyticsAllowed,
+ bool $isDisplayAnalyticsAllowed,
string $jobStatusAfterSync,
QuicksightGenerateEmbedUrlResponseTransfer $quicksightGenerateEmbedUrlResponseTransfer
): void {
// Arrange
$this->tester->getContainer()->set(static::SERVICE_TWIG, $this->getTwigMock(
- $isInitializedAfterSync,
+ $isEnableAnalyticsAllowed,
$isInitializationInProgress,
- true,
+ $isDisplayAnalyticsAllowed,
$quicksightGenerateEmbedUrlResponseTransfer,
(new QuicksightAssetBundleImportJobTransfer())
->setIsInitialized($isInitializedAfterSync)
@@ -291,7 +317,7 @@ public function testExpandsCollectionWhenDescribeAssetBundleImportJobApiRequestF
$this->tester->getContainer()->set(static::SERVICE_TWIG, $this->getTwigMock(
false,
true,
- true,
+ false,
new QuicksightGenerateEmbedUrlResponseTransfer(),
(new QuicksightAssetBundleImportJobTransfer())
->setIsInitialized(false)
@@ -332,7 +358,7 @@ public function testExpandsCollectionWhenGenerateEmbedUrlApiRequestFails(bool $t
{
// Arrange
$this->tester->getContainer()->set(static::SERVICE_TWIG, $this->getTwigMock(
- true,
+ false,
false,
true,
(new QuicksightGenerateEmbedUrlResponseTransfer())
@@ -369,15 +395,19 @@ public function testExpandsCollectionWhenGenerateEmbedUrlApiRequestFails(bool $t
* @dataProvider expandsCollectionWhenQuicksightAssetBundleImportJobFinishedDataProvider
*
* @param bool $isInitializedInitially
+ * @param bool $isEnableAnalyticsAllowed
+ * @param bool $isDisplayAnalyticsAllowed
* @param string $initialJobStatus
* @param \Generated\Shared\Transfer\QuicksightGenerateEmbedUrlResponseTransfer $quicksightGenerateEmbedUrlResponseTransfer
* @param \Generated\Shared\Transfer\QuicksightAssetBundleImportJobTransfer $quicksightAssetBundleImportJobTransfer
- * @param array $errorTransfers
+ * @param list<\Generated\Shared\Transfer\ErrorTransfer> $errorTransfers
*
* @return void
*/
public function testExpandsCollectionWhenQuicksightAssetBundleImportJobFinished(
bool $isInitializedInitially,
+ bool $isEnableAnalyticsAllowed,
+ bool $isDisplayAnalyticsAllowed,
string $initialJobStatus,
QuicksightGenerateEmbedUrlResponseTransfer $quicksightGenerateEmbedUrlResponseTransfer,
QuicksightAssetBundleImportJobTransfer $quicksightAssetBundleImportJobTransfer,
@@ -385,9 +415,9 @@ public function testExpandsCollectionWhenQuicksightAssetBundleImportJobFinished(
): void {
// Arrange
$this->tester->getContainer()->set(static::SERVICE_TWIG, $this->getTwigMock(
- $isInitializedInitially,
+ $isEnableAnalyticsAllowed,
false,
- true,
+ $isDisplayAnalyticsAllowed,
$quicksightGenerateEmbedUrlResponseTransfer,
$quicksightAssetBundleImportJobTransfer,
));
@@ -449,13 +479,13 @@ protected function throwsExceptionWhenRequiredPropertiesAreNotSetDataProvider():
}
/**
- * @return array>
+ * @return array>
*/
protected function expandsCollectionWhenQuicksightUserExistsWithRoleDataProvider(): array
{
return [
- 'Author role' => [static::QUICKSIGHT_USER_ROLE_AUTHOR],
- 'Reader role' => [static::QUICKSIGHT_USER_ROLE_READER],
+ 'Author role' => [static::QUICKSIGHT_USER_ROLE_AUTHOR, true],
+ 'Reader role' => [static::QUICKSIGHT_USER_ROLE_READER, false],
];
}
@@ -469,6 +499,8 @@ protected function expandsCollectionWhenQuicksightAssetBundleImportJobIsInProgre
false,
false,
true,
+ false,
+ false,
static::ASSET_BUNDLE_IMPORT_JOB_STATUS_IN_PROGRESS,
new QuicksightGenerateEmbedUrlResponseTransfer(),
],
@@ -476,6 +508,8 @@ protected function expandsCollectionWhenQuicksightAssetBundleImportJobIsInProgre
false,
true,
false,
+ false,
+ true,
static::ASSET_BUNDLE_IMPORT_JOB_STATUS_SUCCESSFUL,
(new QuicksightGenerateEmbedUrlResponseTransfer())->setEmbedUrl((new QuicksightEmbedUrlTransfer())->setUrl(static::EMBED_URL_TEST)),
],
@@ -483,6 +517,8 @@ protected function expandsCollectionWhenQuicksightAssetBundleImportJobIsInProgre
true,
true,
true,
+ false,
+ false,
static::ASSET_BUNDLE_IMPORT_JOB_STATUS_IN_PROGRESS,
(new QuicksightGenerateEmbedUrlResponseTransfer())->setEmbedUrl((new QuicksightEmbedUrlTransfer())->setUrl(static::EMBED_URL_TEST)),
],
@@ -490,6 +526,8 @@ protected function expandsCollectionWhenQuicksightAssetBundleImportJobIsInProgre
true,
true,
false,
+ false,
+ true,
static::ASSET_BUNDLE_IMPORT_JOB_STATUS_SUCCESSFUL,
(new QuicksightGenerateEmbedUrlResponseTransfer())->setEmbedUrl((new QuicksightEmbedUrlTransfer())->setUrl(static::EMBED_URL_TEST)),
],
@@ -525,6 +563,8 @@ protected function expandsCollectionWhenQuicksightAssetBundleImportJobFinishedDa
{
return [
'Job successfully finished' => [
+ true,
+ false,
true,
static::ASSET_BUNDLE_IMPORT_JOB_STATUS_SUCCESSFUL,
(new QuicksightGenerateEmbedUrlResponseTransfer())->setEmbedUrl((new QuicksightEmbedUrlTransfer())->setUrl(static::EMBED_URL_TEST)),
@@ -536,6 +576,8 @@ protected function expandsCollectionWhenQuicksightAssetBundleImportJobFinishedDa
[],
],
'Reset job finished with errors' => [
+ true,
+ false,
true,
static::ASSET_BUNDLE_IMPORT_JOB_STATUS_FAILED_ROLLBACK_COMPLETED,
(new QuicksightGenerateEmbedUrlResponseTransfer())->setEmbedUrl((new QuicksightEmbedUrlTransfer())->setUrl(static::EMBED_URL_TEST)),
@@ -552,6 +594,8 @@ protected function expandsCollectionWhenQuicksightAssetBundleImportJobFinishedDa
[(new ErrorTransfer())->setMessage(static::ERROR_MESSAGE_DESCRIBE_ASSET_BUNDLE_IMPORT_JOB_FAILED)],
],
'Enable job finished with errors' => [
+ false,
+ true,
false,
static::ASSET_BUNDLE_IMPORT_JOB_STATUS_FAILED_ROLLBACK_COMPLETED,
new QuicksightGenerateEmbedUrlResponseTransfer(),
@@ -571,18 +615,18 @@ protected function expandsCollectionWhenQuicksightAssetBundleImportJobFinishedDa
}
/**
- * @param bool $isAssetBundleSuccessfullyInitialized
+ * @param bool $isEnableAnalyticsAllowed
* @param bool $isAssetBundleInitializationInProgress
- * @param bool $isQuicksightUserRoleAvailable
+ * @param bool $isDisplayAnalyticsAllowed
* @param \Generated\Shared\Transfer\QuicksightGenerateEmbedUrlResponseTransfer $quicksightGenerateEmbedUrlResponseTransfer
* @param \Generated\Shared\Transfer\QuicksightAssetBundleImportJobTransfer|null $quicksightAssetBundleImportJobTransfer
*
* @return \PHPUnit\Framework\MockObject\MockObject|\Twig\Environment
*/
protected function getTwigMock(
- bool $isAssetBundleSuccessfullyInitialized,
+ bool $isEnableAnalyticsAllowed,
bool $isAssetBundleInitializationInProgress,
- bool $isQuicksightUserRoleAvailable,
+ bool $isDisplayAnalyticsAllowed,
QuicksightGenerateEmbedUrlResponseTransfer $quicksightGenerateEmbedUrlResponseTransfer,
?QuicksightAssetBundleImportJobTransfer $quicksightAssetBundleImportJobTransfer = null
): Environment {
@@ -595,15 +639,22 @@ protected function getTwigMock(
[
$this->equalTo(static::TEMPLATE_PATH_QUICKSIGHT_ANALYTICS),
$this->equalTo([
- 'isAssetBundleSuccessfullyInitialized' => $isAssetBundleSuccessfullyInitialized,
+ 'isEnableAnalyticsAllowed' => $isEnableAnalyticsAllowed,
'isAssetBundleInitializationInProgress' => $isAssetBundleInitializationInProgress,
- 'isQuicksightUserRoleAvailable' => $isQuicksightUserRoleAvailable,
+ 'isDisplayAnalyticsAllowed' => $isDisplayAnalyticsAllowed,
'quicksightGenerateEmbedUrlResponse' => $quicksightGenerateEmbedUrlResponseTransfer,
'quicksightAssetBundleImportJob' => $quicksightAssetBundleImportJobTransfer,
]),
],
[
- $this->equalTo(static::TEMPLATE_PATH_QUICKSIGHT_ANALYTICS_ACTIONS),
+ $this->equalTo(static::TEMPLATE_PATH_SYNCHRONIZE_QUICKSIGHT_USERS_ACTION),
+ $this->equalTo([
+ 'formName' => static::FORM_NAME_SYNCHRONIZE_QUICKSIGHT_USERS,
+ 'tokenFieldName' => static::FIELD_NAME_TOKEN,
+ ]),
+ ],
+ [
+ $this->equalTo(static::TEMPLATE_PATH_QUICKSIGHT_ANALYTICS_RESET_ACTION),
$this->equalTo([]),
],
);