From 4d1344008d324a1eeffa09a5fad58d45cde3a4b0 Mon Sep 17 00:00:00 2001 From: tanya732 Date: Fri, 29 Nov 2024 15:13:49 +0530 Subject: [PATCH] udpated test cases --- .../java/com/auth0/client/mgmt/PromptsEntity.java | 3 ++- src/test/java/com/auth0/client/MockServer.java | 1 + .../com/auth0/client/mgmt/PromptsEntityTest.java | 12 ++++++++---- src/test/resources/mgmt/custom_text_prompt.json | 5 +++++ src/test/resources/mgmt/partials_prompt.json | 3 --- 5 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 src/test/resources/mgmt/custom_text_prompt.json diff --git a/src/main/java/com/auth0/client/mgmt/PromptsEntity.java b/src/main/java/com/auth0/client/mgmt/PromptsEntity.java index 639f2aff..5cf9f876 100644 --- a/src/main/java/com/auth0/client/mgmt/PromptsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/PromptsEntity.java @@ -34,8 +34,9 @@ public Request getPrompt() { } /** - * Get the prompt. + * Update the prompt. * A token with {@code update:prompts} scope is required. + * @param prompt the prompt to update. * @return a Request to execute. * * @see https://auth0.com/docs/api/management/v2#!/prompts/patch-prompts diff --git a/src/test/java/com/auth0/client/MockServer.java b/src/test/java/com/auth0/client/MockServer.java index f9e0ced1..cc65cab6 100644 --- a/src/test/java/com/auth0/client/MockServer.java +++ b/src/test/java/com/auth0/client/MockServer.java @@ -86,6 +86,7 @@ public class MockServer { public static final String MGMT_RECOVERY_CODE = "src/test/resources/mgmt/recovery_code.json"; public static final String MGMT_IDENTITIES_LIST = "src/test/resources/mgmt/identities_list.json"; public static final String MGMT_PROMPT = "src/test/resources/mgmt/prompt.json"; + public static final String MGMT_CUSTOM_TEXT_PROMPT = "src/test/resources/mgmt/custom_text_prompt.json"; public static final String MGMT_PARTIALS_PROMPT = "src/test/resources/mgmt/partials_prompt.json"; public static final String MGMT_GUARDIAN_AUTHENTICATION_POLICIES_LIST = "src/test/resources/mgmt/guardian_authentication_policies_list.json"; public static final String MGMT_GUARDIAN_ENROLLMENT = "src/test/resources/mgmt/guardian_enrollment.json"; diff --git a/src/test/java/com/auth0/client/mgmt/PromptsEntityTest.java b/src/test/java/com/auth0/client/mgmt/PromptsEntityTest.java index c8722ae3..435baf3c 100644 --- a/src/test/java/com/auth0/client/mgmt/PromptsEntityTest.java +++ b/src/test/java/com/auth0/client/mgmt/PromptsEntityTest.java @@ -9,8 +9,7 @@ import java.util.HashMap; import java.util.Map; -import static com.auth0.client.MockServer.MGMT_PARTIALS_PROMPT; -import static com.auth0.client.MockServer.MGMT_PROMPT; +import static com.auth0.client.MockServer.*; import static com.auth0.client.RecordedRequestMatcher.hasHeader; import static com.auth0.client.RecordedRequestMatcher.hasMethodAndPath; import static org.hamcrest.MatcherAssert.assertThat; @@ -86,7 +85,7 @@ public void shouldGetCustomText() throws Exception { Request request = api.prompts().getCustomText("login", "en"); assertThat(request, is(notNullValue())); - server.jsonResponse(MGMT_PARTIALS_PROMPT, 200); + server.jsonResponse(MGMT_CUSTOM_TEXT_PROMPT, 200); Object response = request.execute().getBody(); RecordedRequest recordedRequest = server.takeRequest(); @@ -120,11 +119,16 @@ public void shouldThrowOnSetCustomTextWhenCustomTextIsNull() throws Exception { @Test public void shouldSetCustomText() throws Exception { + Map signup = new HashMap<>(); + signup.put("description", "Sign up to access amazing features for my login domain"); + Map customText = new HashMap<>(); + customText.put("signup", signup); + Request request = api.prompts().setCustomText("login", "en", customText); assertThat(request, is(notNullValue())); - server.jsonResponse(MGMT_PARTIALS_PROMPT, 200); + server.jsonResponse(MGMT_CUSTOM_TEXT_PROMPT, 200); request.execute(); RecordedRequest recordedRequest = server.takeRequest(); diff --git a/src/test/resources/mgmt/custom_text_prompt.json b/src/test/resources/mgmt/custom_text_prompt.json new file mode 100644 index 00000000..dd14ae92 --- /dev/null +++ b/src/test/resources/mgmt/custom_text_prompt.json @@ -0,0 +1,5 @@ +{ + "signup": { + "description": "Sign up to access amazing features for my login domain" + } +} diff --git a/src/test/resources/mgmt/partials_prompt.json b/src/test/resources/mgmt/partials_prompt.json index 425dafde..2c63c085 100644 --- a/src/test/resources/mgmt/partials_prompt.json +++ b/src/test/resources/mgmt/partials_prompt.json @@ -1,5 +1,2 @@ { - "login": { - "description": "Login to ACME's Website" - } }