From 1ae81eb6906541b9ef44fd13ba57bd7e0f6f035a Mon Sep 17 00:00:00 2001
From: Sergey Beryozkin <sberyozkin@gmail.com>
Date: Tue, 6 Apr 2021 13:10:28 +0100
Subject: [PATCH] Fix OidcClient test failure

---
 .../client/runtime/OidcClientRecorder.java    | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java b/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java
index 76d70d23432c2..5bfa8f1a952f5 100644
--- a/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java
+++ b/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java
@@ -142,15 +142,17 @@ public OidcClient apply(String tokenRequestUri, Throwable t) {
                                 : OidcConstants.PASSWORD_GRANT;
                         setGrantClientParams(oidcConfig, tokenGrantParams, grantType);
 
-                        Map<String, String> grantOptions = oidcConfig.getGrantOptions()
-                                .get(oidcConfig.grant.getType().name().toLowerCase());
-                        if (oidcConfig.grant.getType() == Grant.Type.PASSWORD) {
-                            tokenGrantParams.add(OidcConstants.PASSWORD_GRANT_USERNAME,
-                                    grantOptions.get(OidcConstants.PASSWORD_GRANT_USERNAME));
-                            tokenGrantParams.add(OidcConstants.PASSWORD_GRANT_PASSWORD,
-                                    grantOptions.get(OidcConstants.PASSWORD_GRANT_PASSWORD));
-                        } else if (grantOptions != null && oidcConfig.grant.getType() == Grant.Type.CLIENT) {
-                            tokenGrantParams.addAll(grantOptions);
+                        if (oidcConfig.getGrantOptions() != null) {
+                            Map<String, String> grantOptions = oidcConfig.getGrantOptions()
+                                    .get(oidcConfig.grant.getType().name().toLowerCase());
+                            if (oidcConfig.grant.getType() == Grant.Type.PASSWORD) {
+                                tokenGrantParams.add(OidcConstants.PASSWORD_GRANT_USERNAME,
+                                        grantOptions.get(OidcConstants.PASSWORD_GRANT_USERNAME));
+                                tokenGrantParams.add(OidcConstants.PASSWORD_GRANT_PASSWORD,
+                                        grantOptions.get(OidcConstants.PASSWORD_GRANT_PASSWORD));
+                            } else if (grantOptions != null && oidcConfig.grant.getType() == Grant.Type.CLIENT) {
+                                tokenGrantParams.addAll(grantOptions);
+                            }
                         }
 
                         MultiMap commonRefreshGrantParams = new MultiMap(io.vertx.core.MultiMap.caseInsensitiveMultiMap());