Class ClientCredentialsRequestFormatterFactoryTest
java.lang.Object
org.apache.kafka.common.security.oauthbearer.internals.secured.OAuthBearerTest
org.apache.kafka.common.security.oauthbearer.internals.secured.ClientCredentialsRequestFormatterFactoryTest
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidvoidvoidvoidThe file-based (static) assertion branch is unchanged: the pre-built JWT is opaque to the factory, so iss/aud/sub configs are neither required nor consumed here.voidvoidThe dynamic-assertion branch must fail fast at configure-time when a required claim is missing, matching the pre-KIP-1258 client-secret flow which also validates upfront.voidvoidvoidvoidvoidTests that when only locally-generated assertion configs are present (no file), the second preference (locally-generated) is used, not the third preference (client secret).voidTests that when no assertion configs are present, the third preference (client secret) is used as the fallback.voidThis test explicitly documents and verifies the three-tier fallback precedence mechanism: 1.voidtestValidateUrlEncodeHeader(Map<String, Object> configs, boolean expectedValue)
-
Constructor Details
-
ClientCredentialsRequestFormatterFactoryTest
public ClientCredentialsRequestFormatterFactoryTest()
-
-
Method Details
-
saveSystemProperty
@BeforeEach public void saveSystemProperty() -
restoreSystemProperty
@AfterEach public void restoreSystemProperty() -
testCreateWithLocalClientAssertionWithUnencryptedPKCS8
-
testCreateWithLocalClientAssertionWithPassphraseOnUnencryptedKey
-
testCreateWithFileClientAssertion
-
testCreateWithClientAssertionThrowsExceptionForInvalidKeyPath
@Test public void testCreateWithClientAssertionThrowsExceptionForInvalidKeyPath() -
testCreateWithClientSecret
@Test public void testCreateWithClientSecret() -
testCreateWithClientSecretFromConfig
@Test public void testCreateWithClientSecretFromConfig() -
testAssertionPathTriggeredByIssConfig
-
testAssertionPathTriggeredByAssertionFileConfig
-
testThreeTierFallbackPrecedence
This test explicitly documents and verifies the three-tier fallback precedence mechanism: 1. First Preference: File-based assertion (sasl.oauthbearer.assertion.file) 2. Second Preference: Locally-generated assertion (sasl.oauthbearer.assertion.claim.iss + private key) 3. Third Preference: Client secret (client.id + client.secret) When multiple authentication methods are configured simultaneously, the first preference takes precedence and other configurations are silently ignored.- Throws:
Exception
-
testSecondPreferenceTakesPrecedenceOverThird
-
testThirdPreferenceUsedWhenNoAssertionConfigs
@Test public void testThirdPreferenceUsedWhenNoAssertionConfigs()Tests that when no assertion configs are present, the third preference (client secret) is used as the fallback. -
testCreateWithNeitherAssertionNorClientCredentials
@Test public void testCreateWithNeitherAssertionNorClientCredentials() -
testCreateWithLocalAssertionFailsWhenAudMissing
-
testCreateWithLocalAssertionFailsWhenSubMissing
-
testCreateWithFileAssertionSkipsClaimValidation
-
testValidateUrlEncodeHeader
-