content: /*
   * Copyright 2021-2024 Aklivity Inc.
   *
   * Aklivity licenses this file to you under the Apache License,
   * version 2.0 (the "License"); you may not use this file except in compliance
   * with the License. You may obtain a copy of the License at:
   *
   *   http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   * License for the specific language governing permissions and limitations
   * under the License.
   */
  package io.aklivity.zilla.runtime.binding.kafka.internal.stream;
  
  import static io.aklivity.zilla.runtime.binding.kafka.internal.KafkaConfigurationTest.KAFKA_CLIENT_SASL_SCRAM_NONCE_NAME;
  import static java.util.concurrent.TimeUnit.SECONDS;
  import static org.junit.rules.RuleChain.outerRule;
  
  import org.junit.Rule;
  import org.junit.Test;
  import org.junit.rules.DisableOnDebug;
  import org.junit.rules.TestRule;
  import org.junit.rules.Timeout;
  
  import io.aklivity.k3po.runtime.junit.annotation.Specification;
  import io.aklivity.k3po.runtime.junit.rules.K3poRule;
  import io.aklivity.zilla.runtime.engine.test.EngineRule;
  import io.aklivity.zilla.runtime.engine.test.annotation.Configuration;
  import io.aklivity.zilla.runtime.engine.test.annotation.Configure;
  
  public class DescribeClusterSaslIT
  {
      private final K3poRule k3po = new K3poRule()
          .addScriptRoot("app", "io/aklivity/zilla/specs/binding/kafka/streams/application/describe.cluster")
          .addScriptRoot("net", "io/aklivity/zilla/specs/binding/kafka/streams/network/describe.cluster.v0.sasl.handshake.v1");
  
      private final TestRule timeout = new DisableOnDebug(new Timeout(5, SECONDS));
  
      private final EngineRule engine = new EngineRule()
          .directory("target/zilla-itests")
          .countersBufferCapacity(8192)
          .configurationRoot("io/aklivity/zilla/specs/binding/kafka/config")
          .external("net0")
          .clean();
  
      @Rule
      public final TestRule chain = outerRule(engine).around(k3po).around(timeout);
  
      @Test
      @Configuration("client.options.sasl.plain.yaml")
      @Specification({
          "${app}/cluster.brokers.info/client",
          "${net}/cluster.brokers.info.sasl.plain/server"})
      public void shouldDescribeClusterBrokerInfoWithSaslPlain() throws Exception
      {
          k3po.finish();
      }
  
      @Test
      @Configuration("client.options.sasl.scram.yaml")
      @Specification({
          "${app}/cluster.brokers.info/client",
          "${net}/cluster.brokers.info.sasl.scram/server"})
      @Configure(name = KAFKA_CLIENT_SASL_SCRAM_NONCE_NAME,
              value = "io.aklivity.zilla.runtime.binding.kafka.internal.stream.DescribeClusterSaslIT::supplyNonce")
      public void shouldDescribeClusterBrokerInfoWithSaslScram() throws Exception
      {
          k3po.finish();
      }
  
      public static String supplyNonce()
      {
          return "fyko+d2lbbFgONRv9qkxdawL";
      }
  }
  