|
20 | 20 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; |
21 | 21 |
|
22 | 22 | import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; |
| 23 | +import com.nimbusds.oauth2.sdk.id.Audience; |
23 | 24 | import io.smallrye.config.SmallRyeConfig; |
24 | 25 | import io.smallrye.config.SmallRyeConfigBuilder; |
25 | 26 | import io.smallrye.config.common.MapBackedConfigSource; |
@@ -149,4 +150,38 @@ void testKeyIdPresent() { |
149 | 150 | smallRyeConfig.getConfigMapping(ClientAssertionConfig.class, PREFIX); |
150 | 151 | assertThat(config.getKeyId()).hasValue("my-key-123"); |
151 | 152 | } |
| 153 | + |
| 154 | + @Test |
| 155 | + void testAudienceSingleValue() { |
| 156 | + Map<String, String> properties = |
| 157 | + Map.of(PREFIX + '.' + ClientAssertionConfig.AUDIENCE, "https://example.com"); |
| 158 | + SmallRyeConfig smallRyeConfig = |
| 159 | + new SmallRyeConfigBuilder() |
| 160 | + .withMapping(ClientAssertionConfig.class, PREFIX) |
| 161 | + .withSources(new MapBackedConfigSource("catalog-properties", properties, 1000) {}) |
| 162 | + .build(); |
| 163 | + ClientAssertionConfig config = |
| 164 | + smallRyeConfig.getConfigMapping(ClientAssertionConfig.class, PREFIX); |
| 165 | + assertThat(config.getAudience()).contains(List.of(new Audience("https://example.com"))); |
| 166 | + } |
| 167 | + |
| 168 | + @Test |
| 169 | + void testAudienceMultipleValues() { |
| 170 | + Map<String, String> properties = |
| 171 | + Map.of( |
| 172 | + PREFIX + '.' + ClientAssertionConfig.AUDIENCE, |
| 173 | + "https://auth1.example.com,https://auth2.example.com"); |
| 174 | + SmallRyeConfig smallRyeConfig = |
| 175 | + new SmallRyeConfigBuilder() |
| 176 | + .withMapping(ClientAssertionConfig.class, PREFIX) |
| 177 | + .withSources(new MapBackedConfigSource("catalog-properties", properties, 1000) {}) |
| 178 | + .build(); |
| 179 | + ClientAssertionConfig config = |
| 180 | + smallRyeConfig.getConfigMapping(ClientAssertionConfig.class, PREFIX); |
| 181 | + assertThat(config.getAudience()) |
| 182 | + .contains( |
| 183 | + List.of( |
| 184 | + new Audience("https://auth1.example.com"), |
| 185 | + new Audience("https://auth2.example.com"))); |
| 186 | + } |
152 | 187 | } |
0 commit comments