Skip to content

Commit 26e6d66

Browse files
committed
Add unit tests
1 parent f61183a commit 26e6d66

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/ClientAssertionConfigTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,44 @@ void testKeyIdPresent() {
149149
smallRyeConfig.getConfigMapping(ClientAssertionConfig.class, PREFIX);
150150
assertThat(config.getKeyId()).hasValue("my-key-123");
151151
}
152+
153+
@Test
154+
void testAudienceSingle() {
155+
Map<String, String> properties =
156+
Map.of(PREFIX + '.' + ClientAssertionConfig.AUDIENCE, "https://auth.example.com");
157+
SmallRyeConfig smallRyeConfig =
158+
new SmallRyeConfigBuilder()
159+
.withMapping(ClientAssertionConfig.class, PREFIX)
160+
.withSources(new MapBackedConfigSource("catalog-properties", properties, 1000) {})
161+
.build();
162+
ClientAssertionConfig config =
163+
smallRyeConfig.getConfigMapping(ClientAssertionConfig.class, PREFIX);
164+
assertThat(config.getAudience())
165+
.hasSize(1)
166+
.extracting("value")
167+
.containsExactly("https://auth.example.com");
168+
assertThat(config.getAudienceString()).hasValue("https://auth.example.com");
169+
}
170+
171+
@Test
172+
void testAudienceMultiple() {
173+
Map<String, String> properties =
174+
Map.of(
175+
PREFIX + '.' + ClientAssertionConfig.AUDIENCE,
176+
"https://auth1.example.com,https://auth2.example.com,https://auth3.example.com");
177+
SmallRyeConfig smallRyeConfig =
178+
new SmallRyeConfigBuilder()
179+
.withMapping(ClientAssertionConfig.class, PREFIX)
180+
.withSources(new MapBackedConfigSource("catalog-properties", properties, 1000) {})
181+
.build();
182+
ClientAssertionConfig config =
183+
smallRyeConfig.getConfigMapping(ClientAssertionConfig.class, PREFIX);
184+
assertThat(config.getAudience())
185+
.hasSize(3)
186+
.extracting("value")
187+
.containsExactly(
188+
"https://auth1.example.com", "https://auth2.example.com", "https://auth3.example.com");
189+
assertThat(config.getAudienceString())
190+
.hasValue("https://auth1.example.com,https://auth2.example.com,https://auth3.example.com");
191+
}
152192
}

0 commit comments

Comments
 (0)