mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 11:23:10 +02:00
SaaS Consolidation (#6384)
Co-authored-by: ConnorYoh <[email protected]>
This commit is contained in:
co-authored by
ConnorYoh
parent
089de247b4
commit
9d081d1792
+49
@@ -0,0 +1,49 @@
|
||||
package stirling.software.proprietary.security.supabase;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.security.oauth2.jwt.JwtDecoder;
|
||||
import org.springframework.security.oauth2.jwt.JwtException;
|
||||
|
||||
class SupabaseJwtDecoderFactoryTest {
|
||||
|
||||
@Test
|
||||
void factoryReturnsFailClosedDecoderWhenIssuerMissing() {
|
||||
SupabaseUserLoginProperties props = new SupabaseUserLoginProperties();
|
||||
props.setEnabled(true);
|
||||
// issuer intentionally not set
|
||||
SupabaseJwtDecoderFactory factory = new SupabaseJwtDecoderFactory(props);
|
||||
|
||||
JwtDecoder decoder = factory.supabaseUserLoginJwtDecoder();
|
||||
|
||||
assertThatThrownBy(() -> decoder.decode("any-token"))
|
||||
.isInstanceOf(JwtException.class)
|
||||
.hasMessageContaining("not configured");
|
||||
}
|
||||
|
||||
@Test
|
||||
void jwtConfiguredReflectsBothEnabledAndIssuer() {
|
||||
SupabaseUserLoginProperties props = new SupabaseUserLoginProperties();
|
||||
|
||||
assertThat(props.isJwtConfigured()).isFalse();
|
||||
|
||||
props.setEnabled(true);
|
||||
assertThat(props.isJwtConfigured()).isFalse();
|
||||
|
||||
props.setIssuer("https://example.supabase.co/auth/v1");
|
||||
assertThat(props.isJwtConfigured()).isTrue();
|
||||
|
||||
props.setEnabled(false);
|
||||
assertThat(props.isJwtConfigured()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void blankIssuerCountsAsUnconfigured() {
|
||||
SupabaseUserLoginProperties props = new SupabaseUserLoginProperties();
|
||||
props.setEnabled(true);
|
||||
props.setIssuer(" ");
|
||||
assertThat(props.isJwtConfigured()).isFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user