Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng committed Apr 7, 2024
1 parent c50df84 commit 4c004a9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pulsar-function-go/pf/instanceConf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package pf

import (
"encoding/json"
"fmt"
"testing"

Expand Down Expand Up @@ -320,3 +321,26 @@ func TestInstanceConf_WithEmptyOrInvalidDetails(t *testing.T) {
})
}
}

func TestInstanceConf_WithOAuth2Parameters(t *testing.T) {
cfg := &cfg.Conf{
AutoACK: true,
ClientAuthenticationPlugin: "org.apache.pulsar.client.impl.auth.AuthenticationOAuth2",
ClientAuthenticationParameters: `{"issuerUrl":"https://test.com","audience":"test-audience",
"scope":"test-scope","privateKey":"/mnt/secrets/auth.json","type":"client_credentials","clientId":"test-client-id"}`,
}

instanceConf := newInstanceConfWithConf(cfg)
assert.Equal(t, cfg.ClientAuthenticationPlugin, instanceConf.authPlugin)
var authMap map[string]string
err := json.Unmarshal([]byte(instanceConf.authParams), &authMap)
assert.Equal(t, err, nil)
assert.Equal(t, authMap, map[string]string{
"issuerUrl": "https://test.com",
"audience": "test-audience",
"scope": "test-scope",
"privateKey": "/mnt/secrets/auth.json",
"type": "client_credentials",
"clientId": "test-client-id",
})
}

0 comments on commit 4c004a9

Please sign in to comment.