Class ClientCredentialsRequestFormatterFactoryTest

java.lang.Object
org.apache.kafka.common.security.oauthbearer.internals.secured.OAuthBearerTest
org.apache.kafka.common.security.oauthbearer.internals.secured.ClientCredentialsRequestFormatterFactoryTest

public class ClientCredentialsRequestFormatterFactoryTest extends OAuthBearerTest
  • Constructor Details

    • ClientCredentialsRequestFormatterFactoryTest

      public ClientCredentialsRequestFormatterFactoryTest()
  • Method Details

    • saveSystemProperty

      @BeforeEach public void saveSystemProperty()
    • restoreSystemProperty

      @AfterEach public void restoreSystemProperty()
    • testCreateWithLocalClientAssertionWithUnencryptedPKCS8

      @Test public void testCreateWithLocalClientAssertionWithUnencryptedPKCS8() throws Exception
      Throws:
      Exception
    • testCreateWithLocalClientAssertionWithPassphraseOnUnencryptedKey

      @Test public void testCreateWithLocalClientAssertionWithPassphraseOnUnencryptedKey() throws Exception
      Throws:
      Exception
    • testCreateWithFileClientAssertion

      @Test public void testCreateWithFileClientAssertion() throws Exception
      Throws:
      Exception
    • testCreateWithClientAssertionThrowsExceptionForInvalidKeyPath

      @Test public void testCreateWithClientAssertionThrowsExceptionForInvalidKeyPath()
    • testCreateWithClientSecret

      @Test public void testCreateWithClientSecret()
    • testCreateWithClientSecretFromConfig

      @Test public void testCreateWithClientSecretFromConfig()
    • testAssertionPathTriggeredByIssConfig

      @Test public void testAssertionPathTriggeredByIssConfig() throws Exception
      Throws:
      Exception
    • testAssertionPathTriggeredByAssertionFileConfig

      @Test public void testAssertionPathTriggeredByAssertionFileConfig() throws Exception
      Throws:
      Exception
    • testThreeTierFallbackPrecedence

      @Test public void testThreeTierFallbackPrecedence() throws Exception
      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

      @Test public void testSecondPreferenceTakesPrecedenceOverThird() throws Exception
      Tests that when only locally-generated assertion configs are present (no file), the second preference (locally-generated) is used, not the third preference (client secret).
      Throws:
      Exception
    • 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

      @Test public void testCreateWithLocalAssertionFailsWhenAudMissing() throws Exception
      The 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.
      Throws:
      Exception
    • testCreateWithLocalAssertionFailsWhenSubMissing

      @Test public void testCreateWithLocalAssertionFailsWhenSubMissing() throws Exception
      Throws:
      Exception
    • testCreateWithFileAssertionSkipsClaimValidation

      @Test public void testCreateWithFileAssertionSkipsClaimValidation() throws Exception
      The 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.
      Throws:
      Exception
    • testValidateUrlEncodeHeader

      @ParameterizedTest @MethodSource("urlEncodeHeaderSupplier") public void testValidateUrlEncodeHeader(Map<String,Object> configs, boolean expectedValue)