From e7f14d64ef2c284af99690834a8927f15ace392a Mon Sep 17 00:00:00 2001 From: aram price <aram.price@broadcom.com> Date: Wed, 11 Sep 2024 10:43:26 -0700 Subject: [PATCH] s3-config-validator specs use non-root user This fixes an issue in CI where `root` has no restrictions on file access resulting in tests which expect to verify when files are _not_ accessible. --- s3-config-validator/Makefile | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/s3-config-validator/Makefile b/s3-config-validator/Makefile index f84eb4f3..25e1045c 100644 --- a/s3-config-validator/Makefile +++ b/s3-config-validator/Makefile @@ -12,9 +12,22 @@ artifact: build build: ./build_all.sh +ifeq ($(shell whoami), root) +NON_ROOT_USER='bbr' test-unit: - cd src/ && \ - go run github.com/onsi/ginkgo/v2/ginkgo -r --keep-going internal + cd src/ \ + && chmod -R g+w . \ + && useradd --groups root --create-home $(NON_ROOT_USER) \ + && set +x; \ + su $(NON_ROOT_USER) -c 'go run github.com/onsi/ginkgo/v2/ginkgo -r --keep-going internal'; \ + status=$$?; \ + userdel --remove bbr \ + && exit $${status} +else +test-unit: + cd src/ \ + && go run github.com/onsi/ginkgo/v2/ginkgo -r --keep-going internal +endif test-e2e: cd src/test && \