Skip to content

Commit

Permalink
[PPANTT-183] fix: SessionTag seralization
Browse files Browse the repository at this point in the history
  • Loading branch information
svariant committed Dec 17, 2024
1 parent 038db42 commit c915424
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import software.amazon.awssdk.services.quicksight.QuickSightClient;
import software.amazon.awssdk.services.quicksight.model.GenerateEmbedUrlForAnonymousUserRequest;
import software.amazon.awssdk.services.quicksight.model.GenerateEmbedUrlForAnonymousUserResponse;
import software.amazon.awssdk.services.quicksight.model.SessionTag;

import java.util.List;

Expand All @@ -30,7 +29,7 @@ public AwsQuicksightClient(
.build();
}

public AwsQuicksightClient(QuickSightClient quickSightClient){
public AwsQuicksightClient(QuickSightClient quickSightClient) {
this.quickSightClient = quickSightClient;
}

Expand All @@ -40,14 +39,15 @@ public String generateEmbedUrlForAnonymousUser(
final String namespace,
final List<String> authorizedResourceArns,
final List<String> allowedDomains,
final List<SessionTag> sessionTags
final String sessionTagKey,
final String sessionTagValue
) {
GenerateEmbedUrlForAnonymousUserRequest generateEmbedUrlForAnonymousUserRequest = GenerateEmbedUrlForAnonymousUserRequest.builder()
.awsAccountId(accountId)
.namespace(namespace)
.authorizedResourceArns(authorizedResourceArns)
.experienceConfiguration(e -> e.dashboard(d -> d.initialDashboardId(initialDashboardId)))
.sessionTags(sessionTags)
.sessionTags(s -> s.key(sessionTagKey).value(sessionTagValue).build()) // TODO verify key session tag
.allowedDomains(allowedDomains)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.quicksight.model.SessionTag;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -47,15 +46,14 @@ public AwsQuicksightService(
* @return dashboard's embed url
*/
public QuicksightEmbedUrlResponse generateEmbedUrlForAnonymousUser(String pspTaxCode) {
// TODO verify key session tag
List<SessionTag> sessionTags = Collections.singletonList(SessionTag.builder().key(sessionTagKey).value(pspTaxCode).build());
String embedUrl = awsQuicksightClient.generateEmbedUrlForAnonymousUser(
this.accountId,
this.initialDashboardId,
this.namespace,
this.authorizedResourceArns,
this.allowedDomains,
sessionTags);
sessionTagKey,
pspTaxCode);
QuicksightEmbedUrlResponse quicksightEmbedUrlResponse = new QuicksightEmbedUrlResponse();
quicksightEmbedUrlResponse.setEmbedUrl(embedUrl);
return quicksightEmbedUrlResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import software.amazon.awssdk.services.quicksight.QuickSightClient;
import software.amazon.awssdk.services.quicksight.model.GenerateEmbedUrlForAnonymousUserRequest;
import software.amazon.awssdk.services.quicksight.model.GenerateEmbedUrlForAnonymousUserResponse;
import software.amazon.awssdk.services.quicksight.model.SessionTag;

import java.util.Collections;
import java.util.concurrent.atomic.AtomicReference;
Expand All @@ -28,15 +27,16 @@ class AwsQuicksightClientTest {
@Test
void generateEmbedUrlForAnonymousUserSuccess() {
when(quickSightClient.generateEmbedUrlForAnonymousUser(any(GenerateEmbedUrlForAnonymousUserRequest.class))).thenReturn(GenerateEmbedUrlForAnonymousUserResponse.builder().embedUrl(EMBED_URL).build());

AtomicReference<String> response = new AtomicReference<>();
assertDoesNotThrow(() -> response.set( sut.generateEmbedUrlForAnonymousUser(
assertDoesNotThrow(() -> response.set(sut.generateEmbedUrlForAnonymousUser(
"accountId",
"dashboardId",
"namespace",
Collections.singletonList("authorizedResourceArns"),
Collections.singletonList("allowed-domain"),
Collections.singletonList(SessionTag.builder().build()))));
"sessionTagKey",
"sessionTagValue")));
assertEquals(EMBED_URL, response.get());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AwsQuicksightServiceTest {

@Test
void generateEmbedUrlForAnonymousUserSuccess() {
when(awsQuicksightClient.generateEmbedUrlForAnonymousUser(anyString(), anyString(), anyString(), any(List.class), any(List.class), any(List.class))).thenReturn(EMBED_URL);
when(awsQuicksightClient.generateEmbedUrlForAnonymousUser(anyString(), anyString(), anyString(), any(List.class), any(List.class), anyString(), anyString())).thenReturn(EMBED_URL);

AtomicReference<QuicksightEmbedUrlResponse> response = new AtomicReference<>();
assertDoesNotThrow(() -> response.set(sut.generateEmbedUrlForAnonymousUser("psp-tax-code")));
Expand Down

0 comments on commit c915424

Please sign in to comment.