[tokenfile]

- the groups field has been changed to a single column option as requested in https://github.com/kubernetes/kubernetes/pull/15704

[docs]
- updated the docs related the the tokefile along with an example
This commit is contained in:
Rohith
2015-10-20 22:36:35 +01:00
parent c8dd1200c4
commit ee691aa1ab
3 changed files with 25 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ import (
"fmt"
"io"
"os"
"strings"
"k8s.io/kubernetes/pkg/auth/user"
)
@@ -58,8 +59,8 @@ func NewCSV(path string) (*TokenAuthenticator, error) {
}
tokens[record[0]] = obj
if len(record) > 3 {
obj.Groups = record[3:]
if len(record) >= 4 {
obj.Groups = strings.Split(record[3], ",")
}
}

View File

@@ -29,8 +29,11 @@ func TestTokenFile(t *testing.T) {
auth, err := newWithContents(t, `
token1,user1,uid1
token2,user2,uid2
token3,user3,uid3,group1,group2
token4,user4,uid4,group2
token3,user3,uid3,"group1,group2"
token4,user4,uid4,"group2"
token5,user5,uid5,group5
token6,user6,uid6,group5,otherdata
token7,user7,uid7,"group1,group2",otherdata
`)
if err != nil {
t.Fatalf("unable to read tokenfile: %v", err)
@@ -64,9 +67,21 @@ token4,user4,uid4,group2
},
{
Token: "token5",
User: &user.DefaultInfo{Name: "user5", UID: "uid5", Groups: []string{"group5"}},
Ok: true,
},
{
Token: "token6",
User: &user.DefaultInfo{Name: "user6", UID: "uid6", Groups: []string{"group5"}},
Ok: true,
},
{
Token: "token7",
User: &user.DefaultInfo{Name: "user7", UID: "uid7", Groups: []string{"group1", "group2"}},
Ok: true,
},
{
Token: "token8",
},
}
for i, testCase := range testCases {