-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide Kong admin token via file (#4808)
Co-authored-by: Tao Yi <richardyi0110@hotmail.com>
- Loading branch information
1 parent
49f6f10
commit 82dbd35
Showing
7 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package manager_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/kong/kubernetes-ingress-controller/v2/internal/manager" | ||
) | ||
|
||
func TestConfigResolve(t *testing.T) { | ||
t.Run("Admin Token Path", func(t *testing.T) { | ||
validWithTokenPath := func() manager.Config { | ||
tempDir := t.TempDir() | ||
tokenFile, err := os.CreateTemp(tempDir, "kong.token") | ||
require.NoError(t, err) | ||
_, err = tokenFile.Write([]byte("non-empty-token")) | ||
require.NoError(t, err) | ||
return manager.Config{ | ||
KongAdminTokenPath: tokenFile.Name(), | ||
} | ||
} | ||
|
||
t.Run("admin token path accepted", func(t *testing.T) { | ||
c := validWithTokenPath() | ||
require.NoError(t, c.Resolve()) | ||
require.Equal(t, c.KongAdminToken, "non-empty-token") | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters