Debian Codegraph @

internal/rpc/kerberos_test.go

raw
1 package rpc
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7 )
8
9 const replacementSPNHost = "nn1.foo.com"
10
11 func TestReplaceSPNHostWildcard(t *testing.T) {
12 tests := []struct {
13 SPN string
14 Expected string
15 }{
16 {"nn/example.com", "nn/example.com"},
17 {"nn/_HOST", "nn/nn1.foo.com"},
18 {"nn/[email protected]", "nn/[email protected]"},
19 {"nn/_HOST/EXAMPLE.COM", "nn/nn1.foo.com/EXAMPLE.COM"},
20 {"nn/_HOSTFOO.COM", "nn/_HOSTFOO.COM"},
21 {"_HOST", "_HOST"},
22 {"/[email protected]", "/[email protected]"},
23 {"_HOST/nn2.foo.com", "_HOST/nn2.foo.com"},
24 {"nn/nn2.foo.com/_HOST", "nn/nn2.foo.com/_HOST"},
25 }
26
27 for _, test := range tests {
28 t.Run("SPN="+test.SPN, func(t *testing.T) {
29 assert.Equal(t, test.Expected, replaceSPNHostWildcard(test.SPN, replacementSPNHost))
30 })
31 }
32 }