From 3a977a74499b45e91364d0f704a7a7ee48a5351f Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 12 Jan 2021 16:32:20 +0100 Subject: Improved config App tests --- config/app.go | 4 ++-- config/app_test.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/app.go b/config/app.go index d7d1051..2eefb98 100644 --- a/config/app.go +++ b/config/app.go @@ -28,8 +28,8 @@ func (a *App) validate() error { if err := os.MkdirAll(a.WorkingDirectory, 0700); err != nil { return errors.Wrapf(err, "Invalid WorkingDirectory : %s", a.WorkingDirectory) } - if err := unix.Access(a.WorkingDirectory, unix.W_OK); err != nil { - return errors.Wrapf(err, "Invalid WorkingDirectory : %s", a.WorkingDirectory) + if err := unix.Access(a.WorkingDirectory, unix.W_OK|unix.R_OK|unix.X_OK); err != nil { + return errors.Wrapf(err, "invalid WorkingDirectory : %s", a.WorkingDirectory) } // MaxUsers if a.MaxUsers <= 0 { diff --git a/config/app_test.go b/config/app_test.go index 22fb891..cda891d 100644 --- a/config/app_test.go +++ b/config/app_test.go @@ -56,4 +56,15 @@ func TestAppvalidate(t *testing.T) { } //PostLoginCommands is tested from command.go + + // A valid App + app = App{ + WorkingDirectory: "var/", + MaxUsers: 512, + MaxNickLen: 15, + MenuMaxIdleTime: 60, + } + if err := app.validate(); err != nil { + t.Fatal("A valid app should pass") + } } -- cgit v1.2.3