Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mfriesen committed Jul 4, 2024
1 parent d78a672 commit 4ba45ad
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 5 deletions.
6 changes: 6 additions & 0 deletions docs/openapi/openapi-iam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9594,6 +9594,12 @@
username:
type: string
description: Username of user
email:
type: string
description: Email of user
enabled:
type: boolean
description: whether the user is enabled
userStatus:
type: string
description: Status of user
Expand Down
6 changes: 6 additions & 0 deletions docs/openapi/openapi-jwt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9594,6 +9594,12 @@
username:
type: string
description: Username of user
email:
type: string
description: Email of user
enabled:
type: boolean
description: whether the user is enabled
userStatus:
type: string
description: Status of user
Expand Down
6 changes: 6 additions & 0 deletions docs/openapi/openapi-key.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9594,6 +9594,12 @@
username:
type: string
description: Username of user
email:
type: string
description: Email of user
enabled:
type: boolean
description: whether the user is enabled
userStatus:
type: string
description: Status of user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9680,6 +9680,12 @@ Resources:
username:
type: "string"
description: "Username of user"
email:
type: "string"
description: "Email of user"
enabled:
type: "boolean"
description: "whether the user is enabled"
userStatus:
type: "string"
description: "Status of user"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9680,6 +9680,12 @@ Resources:
username:
type: "string"
description: "Username of user"
email:
type: "string"
description: "Email of user"
enabled:
type: "boolean"
description: "whether the user is enabled"
userStatus:
type: "string"
description: "Status of user"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9680,6 +9680,12 @@ Resources:
username:
type: "string"
description: "Username of user"
email:
type: "string"
description: "Email of user"
enabled:
type: "boolean"
description: "whether the user is enabled"
userStatus:
type: "string"
description: "Status of user"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.Arrays;
Expand Down Expand Up @@ -110,7 +111,7 @@ public void testGetUsers01() throws Exception {
// given
List<ApiClient> clients = getApiClients(null);

for (ApiClient client : clients) {
for (ApiClient client : getAdminClients(clients)) {

UserManagementApi userApi = new UserManagementApi(client);

Expand All @@ -124,9 +125,23 @@ public void testGetUsers01() throws Exception {
User user = users.get(0);
assertNotNull(user.getUsername());
assertNotNull(user.getUserStatus());
assertNotNull(user.getEmail());
assertTrue(user.getEnabled());
assertNotNull(user.getInsertedDate());
assertNotNull(user.getLastModifiedDate());
}

// given
UserManagementApi userApi = new UserManagementApi(clients.get(2));

// when
try {
userApi.getUsers(null, null);
fail();
} catch (ApiException e) {
// then
assertEquals(ApiResponseStatus.SC_UNAUTHORIZED.getStatusCode(), e.getCode());
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package com.formkiq.stacks.api.transformers;

import com.formkiq.aws.dynamodb.objects.DateUtil;
import software.amazon.awssdk.services.cognitoidentityprovider.model.AttributeType;
import software.amazon.awssdk.services.cognitoidentityprovider.model.UserType;

import java.text.SimpleDateFormat;
Expand All @@ -41,11 +42,14 @@ public class UsersResponseToMap implements Function<UserType, Map<String, Object
private final SimpleDateFormat df = DateUtil.getIsoDateFormatter();

@Override
public Map<String, Object> apply(final UserType u) {
public Map<String, Object> apply(final UserType ut) {

return Map.of("username", u.username(), "userStatus", u.userStatus().name(), "enabled",
String.valueOf(u.enabled()), "insertedDate", toString(u.userCreateDate()),
"lastModifiedDate", toString(u.userLastModifiedDate()));
String email = ut.attributes().stream().filter(u -> "email".equalsIgnoreCase(u.name()))
.map(AttributeType::value).findAny().orElse("");

return Map.of("username", ut.username(), "email", email, "userStatus", ut.userStatus().name(),
"enabled", ut.enabled(), "insertedDate", toString(ut.userCreateDate()), "lastModifiedDate",
toString(ut.userLastModifiedDate()));
}

private String toString(final Instant date) {
Expand Down

0 comments on commit 4ba45ad

Please sign in to comment.