go-hep.org/x/hep@v0.38.1/xrootd/xrdproto/auth/unix/unix_test.go (about) 1 // Copyright ©2018 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package unix_test 6 7 import ( 8 "testing" 9 10 "go-hep.org/x/hep/xrootd/xrdproto/auth" 11 "go-hep.org/x/hep/xrootd/xrdproto/auth/unix" 12 ) 13 14 func TestUnix(t *testing.T) { 15 v := unix.Auth{User: "gopher", Group: "golang"} 16 if got, want := v.Provider(), "unix"; got != want { 17 t.Fatalf("invalid provider: got=%q, want=%q", got, want) 18 } 19 20 if got, want := v.Provider(), string(unix.Type[:]); got != want { 21 t.Fatalf("invalid provider type: got=%q, want=%q", got, want) 22 } 23 24 want := &auth.Request{Type: unix.Type, Credentials: "unix\000gopher golang\000"} 25 26 got, err := v.Request(nil) 27 if err != nil { 28 t.Fatalf("request error: %v", err) 29 } 30 31 if got.Credentials != want.Credentials { 32 t.Fatalf("invalid credentials:\ngot= %q\nwant=%q\n", got.Credentials, want.Credentials) 33 } 34 35 if got.Type != want.Type { 36 t.Fatalf("invalid type: got=%q, want=%q", got.Type, want.Type) 37 } 38 }