tao12345666333 commented on code in PR #1035:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/1035#discussion_r881925503


##########
pkg/kube/translation/plugin_test.go:
##########
@@ -914,25 +914,111 @@ func TestTranslateConsumerWolfRBACWithSecretRef(t 
*testing.T) {
        assert.Nil(t, err)
        <-processCh
 
-       cfg, err = tr.translateConsumerWolfRBACPluginV2beta3("default", 
wolfRBAC)
+       _, err = tr.translateConsumerWolfRBACPluginV2beta3("default", wolfRBAC)
        assert.Nil(t, err)
 
        delete(sec.Data, "appid")
        _, err = 
client.CoreV1().Secrets("default").Update(context.Background(), sec, 
metav1.UpdateOptions{})
        assert.Nil(t, err)
        <-processCh
 
-       cfg, err = tr.translateConsumerWolfRBACPluginV2beta3("default", 
wolfRBAC)
+       _, err = tr.translateConsumerWolfRBACPluginV2beta3("default", wolfRBAC)
        assert.Nil(t, err)
 
        delete(sec.Data, "header_prefix")
        _, err = 
client.CoreV1().Secrets("default").Update(context.Background(), sec, 
metav1.UpdateOptions{})
        assert.Nil(t, err)
        <-processCh
 
-       cfg, err = tr.translateConsumerWolfRBACPluginV2beta3("default", 
wolfRBAC)
+       _, err = tr.translateConsumerWolfRBACPluginV2beta3("default", wolfRBAC)
        assert.Nil(t, err)
 
        close(processCh)
        close(stopCh)
 }
+
+func TestTranslateConsumerHMACAuthPluginWithInPlaceValue(t *testing.T) {
+       hmacAuth := &configv2beta3.ApisixConsumerHMACAuth{
+               Value: &configv2beta3.ApisixConsumerHMACAuthValue{
+                       AccessKey:     "foo",
+                       SecretKey:     "foo-secret",
+                       ClockSkew:     0,
+                       SignedHeaders: []string{"User-Agent"},
+               },
+       }
+       cfg, err := 
(&translator{}).translateConsumerHMACAuthPluginV2beta3("default", hmacAuth)
+       assert.Nil(t, err)
+       assert.Equal(t, "foo", cfg.AccessKey)
+       assert.Equal(t, "foo-secret", cfg.SecretKey)
+       assert.Equal(t, int64(0), cfg.ClockSkew)
+       assert.Equal(t, []string{"User-Agent"}, cfg.SignedHeaders)
+}
+
+func TestTranslateConsumerHMACAuthPluginWithSecretRed(t *testing.T) {

Review Comment:
   ```suggestion
   func TestTranslateConsumerHMACAuthPluginWithSecretRef(t *testing.T) {
   ```
   
   do you mean Ref?



##########
test/e2e/suite-features/consumer.go:
##########
@@ -636,6 +636,208 @@ spec:
                assert.Contains(ginkgo.GinkgoT(), msg401, "Missing rbac token 
in request")
        })
 
+       ginkgo.It("ApisixRoute with hmacAuth consumer", func() {
+               ac := `
+apiVersion: apisix.apache.org/v2beta3
+kind: ApisixConsumer
+metadata:
+  name: hmacvalue
+spec:
+  authParameter:
+    hmacAuth:
+      value:
+        access_key: papa
+        secret_key: fatpa
+        algorithm: "hmac-sha256"
+        clock_skew: 0
+`
+               assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ac), 
"creating hmacAuth ApisixConsumer")
+
+               // Wait until the ApisixConsumer create event was delivered.
+               time.Sleep(6 * time.Second)
+
+               grs, err := s.ListApisixConsumers()
+               assert.Nil(ginkgo.GinkgoT(), err, "listing consumer")
+               assert.Len(ginkgo.GinkgoT(), grs, 1)
+               assert.Len(ginkgo.GinkgoT(), grs[0].Plugins, 1)
+               hmacAuth, _ := 
grs[0].Plugins["hmac-auth"].(map[string]interface{})
+               assert.Equal(ginkgo.GinkgoT(), hmacAuth["access_key"], "papa")
+               assert.Equal(ginkgo.GinkgoT(), hmacAuth["secret_key"], "fatpa")
+               assert.Equal(ginkgo.GinkgoT(), hmacAuth["algorithm"], 
"hmac-sha256")
+               assert.Equal(ginkgo.GinkgoT(), hmacAuth["clock_skew"], 
float64(0))
+

Review Comment:
   Equal(t, expected, actual, msgAndArgs)
   
   You need to modify the order of the parameters



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to