|
17 | 17 | package io.supertokens.test.multitenant.api; |
18 | 18 |
|
19 | 19 | import com.google.gson.Gson; |
| 20 | +import com.google.gson.GsonBuilder; |
20 | 21 | import com.google.gson.JsonObject; |
21 | 22 | import io.supertokens.ProcessState; |
22 | 23 | import io.supertokens.featureflag.EE_FEATURES; |
|
40 | 41 | import org.junit.Test; |
41 | 42 |
|
42 | 43 | import java.io.IOException; |
| 44 | +import java.util.HashMap; |
| 45 | +import java.util.Map; |
43 | 46 |
|
44 | 47 | import static org.junit.Assert.*; |
45 | 48 |
|
@@ -106,6 +109,44 @@ public void testAddThirdPartyConfig() throws Exception { |
106 | 109 | assertEquals(new Gson().toJsonTree(provider), resultProvider); |
107 | 110 | } |
108 | 111 |
|
| 112 | + @Test |
| 113 | + public void testAddThirdPartyConfigWithNullValues() throws Exception { |
| 114 | + if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { |
| 115 | + return; |
| 116 | + } |
| 117 | + |
| 118 | + JsonObject objWithNulls = new JsonObject(); |
| 119 | + objWithNulls.addProperty("key1", "value"); |
| 120 | + objWithNulls.add("key2", null); |
| 121 | + |
| 122 | + ThirdPartyConfig.Provider provider = new ThirdPartyConfig.Provider( |
| 123 | + "google", |
| 124 | + "Google", |
| 125 | + null, |
| 126 | + null, |
| 127 | + objWithNulls, |
| 128 | + null, |
| 129 | + objWithNulls, |
| 130 | + null, |
| 131 | + objWithNulls, |
| 132 | + objWithNulls, |
| 133 | + null, |
| 134 | + null, |
| 135 | + null, |
| 136 | + null |
| 137 | + ); |
| 138 | + JsonObject response = TestMultitenancyAPIHelper.addOrUpdateThirdPartyProviderConfig( |
| 139 | + new TenantIdentifier(null, null, null), |
| 140 | + provider, |
| 141 | + process.getProcess() |
| 142 | + ); |
| 143 | + assertTrue(response.get("createdNew").getAsBoolean()); |
| 144 | + |
| 145 | + response = TestMultitenancyAPIHelper.getTenant(new TenantIdentifier(null, null, null), process.getProcess()); |
| 146 | + JsonObject resultProvider = response.get("thirdParty").getAsJsonObject().get("providers").getAsJsonArray().get(0).getAsJsonObject(); |
| 147 | + assertEquals(provider.toJson(), resultProvider); |
| 148 | + } |
| 149 | + |
109 | 150 | @Test |
110 | 151 | public void testUpdateThirdPartyConfig() throws Exception { |
111 | 152 | if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { |
|
0 commit comments