mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Clean up auth test slightly
This commit is contained in:
parent
39fba7c8d5
commit
78d0e74b20
@ -36,8 +36,6 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/authorizer"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/authorizer"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -55,15 +53,15 @@ xyz987,bob,2
|
|||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
func writeTestTokenFile() string {
|
func writeTestTokenFile(t *testing.T) string {
|
||||||
// Write a token file.
|
// Write a token file.
|
||||||
f, err := ioutil.TempFile("", "auth_integration_test")
|
f, err := ioutil.TempFile("", "auth_integration_test")
|
||||||
f.Close()
|
f.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(f.Name(), []byte(TokenfileCSV), 0700); err != nil {
|
if err := ioutil.WriteFile(f.Name(), []byte(TokenfileCSV), 0700); err != nil {
|
||||||
glog.Fatalf("unexpected error writing tokenfile: %v", err)
|
t.Fatalf("unexpected error writing tokenfile: %v", err)
|
||||||
}
|
}
|
||||||
return f.Name()
|
return f.Name()
|
||||||
}
|
}
|
||||||
@ -80,7 +78,7 @@ func TestWhoAmI(t *testing.T) {
|
|||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenFilename := writeTestTokenFile()
|
tokenFilename := writeTestTokenFile(t)
|
||||||
defer os.Remove(tokenFilename)
|
defer os.Remove(tokenFilename)
|
||||||
m := master.New(&master.Config{
|
m := master.New(&master.Config{
|
||||||
EtcdHelper: helper,
|
EtcdHelper: helper,
|
||||||
@ -463,7 +461,7 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
|
|||||||
|
|
||||||
deleteAllEtcdKeys()
|
deleteAllEtcdKeys()
|
||||||
|
|
||||||
tokenFilename := writeTestTokenFile()
|
tokenFilename := writeTestTokenFile(t)
|
||||||
defer os.Remove(tokenFilename)
|
defer os.Remove(tokenFilename)
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
|
|
||||||
@ -517,7 +515,7 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
|
|||||||
func TestBobIsForbidden(t *testing.T) {
|
func TestBobIsForbidden(t *testing.T) {
|
||||||
deleteAllEtcdKeys()
|
deleteAllEtcdKeys()
|
||||||
|
|
||||||
tokenFilename := writeTestTokenFile()
|
tokenFilename := writeTestTokenFile(t)
|
||||||
defer os.Remove(tokenFilename)
|
defer os.Remove(tokenFilename)
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
|
|
||||||
@ -573,7 +571,7 @@ func TestBobIsForbidden(t *testing.T) {
|
|||||||
func TestUnknownUserIsUnauthorized(t *testing.T) {
|
func TestUnknownUserIsUnauthorized(t *testing.T) {
|
||||||
deleteAllEtcdKeys()
|
deleteAllEtcdKeys()
|
||||||
|
|
||||||
tokenFilename := writeTestTokenFile()
|
tokenFilename := writeTestTokenFile(t)
|
||||||
defer os.Remove(tokenFilename)
|
defer os.Remove(tokenFilename)
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user