@ -161,14 +161,40 @@ func TestShouldDenyServeConfigForGOOSAndUserContext(t *testing.T) {
goos string
goos string
configIn * ipn . ServeConfig
configIn * ipn . ServeConfig
h * Handler
h * Handler
want bool
want Err bool
} {
} {
{
{
name : "linux" ,
name : "linux" ,
goos : "linux" ,
goos : "linux" ,
configIn : & ipn . ServeConfig { } ,
configIn : & ipn . ServeConfig { } ,
h : & Handler { CallerIsLocalAdmin : false } ,
h : & Handler { CallerIsLocalAdmin : false } ,
want : false ,
wantErr : false ,
} ,
{
name : "linux-path-handler-admin" ,
goos : "linux" ,
configIn : & ipn . ServeConfig {
Web : map [ ipn . HostPort ] * ipn . WebServerConfig {
"foo.test.ts.net:443" : { Handlers : map [ string ] * ipn . HTTPHandler {
"/" : { Path : "/tmp" } ,
} } ,
} ,
} ,
h : & Handler { CallerIsLocalAdmin : true } ,
wantErr : false ,
} ,
{
name : "linux-path-handler-not-admin" ,
goos : "linux" ,
configIn : & ipn . ServeConfig {
Web : map [ ipn . HostPort ] * ipn . WebServerConfig {
"foo.test.ts.net:443" : { Handlers : map [ string ] * ipn . HTTPHandler {
"/" : { Path : "/tmp" } ,
} } ,
} ,
} ,
h : & Handler { CallerIsLocalAdmin : false } ,
wantErr : true ,
} ,
} ,
{
{
name : "windows-not-path-handler" ,
name : "windows-not-path-handler" ,
@ -181,7 +207,7 @@ func TestShouldDenyServeConfigForGOOSAndUserContext(t *testing.T) {
} ,
} ,
} ,
} ,
h : & Handler { CallerIsLocalAdmin : false } ,
h : & Handler { CallerIsLocalAdmin : false } ,
want : false ,
want Err : false ,
} ,
} ,
{
{
name : "windows-path-handler-admin" ,
name : "windows-path-handler-admin" ,
@ -194,7 +220,7 @@ func TestShouldDenyServeConfigForGOOSAndUserContext(t *testing.T) {
} ,
} ,
} ,
} ,
h : & Handler { CallerIsLocalAdmin : true } ,
h : & Handler { CallerIsLocalAdmin : true } ,
want : false ,
want Err : false ,
} ,
} ,
{
{
name : "windows-path-handler-not-admin" ,
name : "windows-path-handler-not-admin" ,
@ -207,15 +233,16 @@ func TestShouldDenyServeConfigForGOOSAndUserContext(t *testing.T) {
} ,
} ,
} ,
} ,
h : & Handler { CallerIsLocalAdmin : false } ,
h : & Handler { CallerIsLocalAdmin : false } ,
want : true ,
want Err : true ,
} ,
} ,
}
}
for _ , tt := range tests {
for _ , tt := range tests {
t . Run ( tt . name , func ( t * testing . T ) {
t . Run ( tt . name , func ( t * testing . T ) {
got := shouldDenyServeConfigForGOOSAndUserContext ( tt . goos , tt . configIn , tt . h )
err := authorizeServeConfigForGOOSAndUserContext ( tt . goos , tt . configIn , tt . h )
if got != tt . want {
gotErr := err != nil
t . Errorf ( "shouldDenyServeConfigForGOOSAndUserContext() got = %v, want %v" , got , tt . want )
if gotErr != tt . wantErr {
t . Errorf ( "authorizeServeConfigForGOOSAndUserContext() got error = %v, want error %v" , err , tt . wantErr )
}
}
} )
} )
}
}