From 7fadf5bad7b2843159f9f2384e9376a5f915b221 Mon Sep 17 00:00:00 2001 From: Marcos Lilljedahl Date: Sat, 3 Oct 2020 10:01:44 -0300 Subject: [PATCH] Remove UserGet call in tests since it's note required for anon sessions Signed-off-by: Marcos Lilljedahl --- pwd/client_test.go | 3 --- pwd/instance_test.go | 3 --- pwd/session.go | 1 - pwd/session_test.go | 1 - 4 files changed, 8 deletions(-) diff --git a/pwd/client_test.go b/pwd/client_test.go index accc758..af30718 100644 --- a/pwd/client_test.go +++ b/pwd/client_test.go @@ -33,7 +33,6 @@ func TestClientNew(t *testing.T) { _d.On("DaemonHost").Return("localhost") _d.On("NetworkConnect", config.L2ContainerName, "aaaabbbbcccc", "").Return("10.0.0.1", nil) _s.On("SessionPut", mock.AnythingOfType("*types.Session")).Return(nil) - _s.On("UserGet", mock.Anything).Return(&types.User{}, nil) _s.On("SessionCount").Return(1, nil) _s.On("InstanceCount").Return(0, nil) _s.On("ClientCount").Return(1, nil) @@ -77,7 +76,6 @@ func TestClientCount(t *testing.T) { _d.On("DaemonHost").Return("localhost") _d.On("NetworkConnect", config.L2ContainerName, "aaaabbbbcccc", "").Return("10.0.0.1", nil) _s.On("SessionPut", mock.AnythingOfType("*types.Session")).Return(nil) - _s.On("UserGet", mock.Anything).Return(&types.User{}, nil) _s.On("ClientPut", mock.AnythingOfType("*types.Client")).Return(nil) _s.On("ClientCount").Return(1, nil) _s.On("SessionCount").Return(1, nil) @@ -120,7 +118,6 @@ func TestClientResizeViewPort(t *testing.T) { _d.On("NetworkConnect", config.L2ContainerName, "aaaabbbbcccc", "").Return("10.0.0.1", nil) _s.On("SessionPut", mock.AnythingOfType("*types.Session")).Return(nil) _s.On("SessionCount").Return(1, nil) - _s.On("UserGet", mock.Anything).Return(&types.User{}, nil) _s.On("InstanceCount").Return(0, nil) _s.On("InstanceFindBySessionId", "aaaabbbbcccc").Return([]*types.Instance{}, nil) _s.On("ClientPut", mock.AnythingOfType("*types.Client")).Return(nil) diff --git a/pwd/instance_test.go b/pwd/instance_test.go index 5bc7133..c50b335 100644 --- a/pwd/instance_test.go +++ b/pwd/instance_test.go @@ -61,7 +61,6 @@ func TestInstanceNew(t *testing.T) { _d.On("NetworkConnect", config.L2ContainerName, "aaaabbbbcccc", "").Return("10.0.0.1", nil) _s.On("SessionPut", mock.AnythingOfType("*types.Session")).Return(nil) _s.On("SessionCount").Return(1, nil) - _s.On("UserGet", mock.Anything).Return(&types.User{}, nil) _s.On("ClientCount").Return(0, nil) _s.On("InstanceCount").Return(0, nil) _s.On("InstanceFindBySessionId", "aaaabbbbcccc").Return([]*types.Instance{}, nil) @@ -135,7 +134,6 @@ func TestInstanceNew_WithNotAllowedImage(t *testing.T) { _d.On("NetworkConnect", config.L2ContainerName, "aaaabbbbcccc", "").Return("10.0.0.1", nil) _s.On("SessionPut", mock.AnythingOfType("*types.Session")).Return(nil) _s.On("SessionCount").Return(1, nil) - _s.On("UserGet", mock.Anything).Return(&types.User{}, nil) _s.On("ClientCount").Return(0, nil) _s.On("InstanceCount").Return(0, nil) _s.On("InstanceFindBySessionId", "aaaabbbbcccc").Return([]*types.Instance{}, nil) @@ -216,7 +214,6 @@ func TestInstanceNew_WithCustomHostname(t *testing.T) { _d.On("DaemonHost").Return("localhost") _d.On("NetworkConnect", config.L2ContainerName, "aaaabbbbcccc", "").Return("10.0.0.1", nil) _s.On("SessionPut", mock.AnythingOfType("*types.Session")).Return(nil) - _s.On("UserGet", mock.Anything).Return(&types.User{}, nil) _s.On("SessionCount").Return(1, nil) _s.On("ClientCount").Return(0, nil) _s.On("InstanceCount").Return(0, nil) diff --git a/pwd/session.go b/pwd/session.go index a68b5b9..afab89c 100644 --- a/pwd/session.go +++ b/pwd/session.go @@ -64,7 +64,6 @@ func (p *pwd) SessionNew(ctx context.Context, config types.SessionConfig) (*type // Annonymous users should be also allowed to login if config.UserId != "" { if _, err := p.UserGet(config.UserId); errors.Is(err, userBannedError) { - return nil, &AccessDeniedError{err} } else if err != nil { return nil, err diff --git a/pwd/session_test.go b/pwd/session_test.go index 0e06dc6..f4c7fa7 100644 --- a/pwd/session_test.go +++ b/pwd/session_test.go @@ -36,7 +36,6 @@ func TestSessionNew(t *testing.T) { _d.On("DaemonHost").Return("localhost") _d.On("NetworkConnect", config.L2ContainerName, "aaaabbbbcccc", "").Return("10.0.0.1", nil) _s.On("SessionPut", mock.AnythingOfType("*types.Session")).Return(nil) - _s.On("UserGet", mock.Anything).Return(&types.User{}, nil) _s.On("SessionCount").Return(1, nil) _s.On("InstanceCount").Return(0, nil) _s.On("ClientCount").Return(0, nil)