Repository: mateusjunges/laravel-kafka (php)

Issue:
[BUG] Missing SASL Config Due to String Casing
**Describe the bug**
I was trying to debug why my SASL configs were not being loaded.   Everything looked correct, except the `usingSasl()` function below was still returning false.  This was because it checks specifically for uppercase strings, whereas our config was in  lowercase. 

```php
private function usingSasl(): bool
{
    return $this->securityProtocol === 'SASL_PLAINTEXT' || $this->securityProtocol === 'SASL_SSL';
}
```

Because Kafka itself seems to understand the lowercase `sasl_plaintext` values, I suggest we change the function to ignore case by throwing a `strtolower` in there. 

**To Reproduce**
Steps to reproduce the behavior:
1. Setup SASL, but use lowercase `sasl_plaintext` as the security protocol. 
2. See that SASL configs are not loaded via `getConsumerOptions()`

**Expected behavior**
I would expect the SASL configs to be loaded properly regardless of the casing of their values. 



Pull request:
[1.6.x] Fixes #69 - Allow to use SASL with lowercase config keys
This PR fixes #69, allowing to use SASL with lower and uppercase config keys.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9781185..d943536 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
 
 All relevant changes to `mateusjunges/laravel-kafka` will be documented here.
 
+## [2022-01-20 v1.6.1](https://github.com/mateusjunges/laravel-kafka/compare/v1.6.0...v1.6.1)
+### Fixed
+- Fixes [#69](https://github.com/mateusjunges/laravel-kafka/issues/69)
+
 ## [2022-01-10 v1.6.0](https://github.com/mateusjunges/laravel-kafka/compare/v1.5.3...v1.6.0)
 ### Added
 - Add support for `ext-rdkafka` v6.0
diff --git a/src/Config/Config.php b/src/Config/Config.php
index 70cf600..1610803 100644
--- a/src/Config/Config.php
+++ b/src/Config/Config.php
@@ -7,6 +7,9 @@ use Junges\Kafka\Contracts\Consumer;
 
 class Config
 {
+    const SASL_PLAINTEXT = 'SASL_PLAINTEXT';
+    const SASL_SSL = 'SASL_SSL';
+
     public function __construct(
         private string $broker,
         private array $topics,
@@ -105,6 +108,7 @@ class Config
 
     private function usingSasl(): bool
     {
-        return $this->securityProtocol === 'SASL_PLAINTEXT' || $this->securityProtocol === 'SASL_SSL';
+        return strtoupper($this->securityProtocol) === static::SASL_PLAINTEXT
+            || strtoupper($this->securityProtocol) === static::SASL_SSL;
     }
 }


Test patch:
diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php
index 704a5a0..fc9dfd1 100644
--- a/tests/Config/ConfigTest.php
+++ b/tests/Config/ConfigTest.php
@@ -177,4 +177,38 @@ class ConfigTest extends LaravelKafkaTestCase
             $config->getProducerOptions()
         );
     }
+
+    public function testSaslCanBeUsedWithLowercaseConfigKeys()
+    {
+        $config = new Config(
+            broker: 'broker',
+            topics: ['topic'],
+            securityProtocol: 'sasl_plaintext',
+            commit: 1,
+            groupId: 'group',
+            consumer: $this->createMock(Consumer::class),
+            sasl: new Sasl(
+                username: 'username',
+                password: 'password',
+                mechanisms: 'mechanisms',
+                securityProtocol: 'ssl_plaintext',
+            ),
+            dlq: null
+        );
+
+        $expectedOptions = [
+            'compression.codec' => 'snappy',
+            'bootstrap.servers' => 'broker',
+            'metadata.broker.list' => 'broker',
+            'security.protocol' => 'ssl_plaintext',
+            'sasl.mechanisms' => 'mechanisms',
+            'sasl.username' => 'username',
+            'sasl.password' => 'password',
+        ];
+
+        $this->assertEquals(
+            $expectedOptions,
+            $config->getProducerOptions()
+        );
+    }
 }