From fe84ab8ca2fabc8987fcb09fa77219859643d25c Mon Sep 17 00:00:00 2001 From: Ben <1274349+BenMcH@users.noreply.github.com> Date: Sat, 10 Feb 2024 12:06:01 -0600 Subject: [PATCH] fix: api regression breaking `blocky blocking disable` (#1373) * fix: Corrects ability to disable all blocking from the CLI by not providing any groups * fix: More appropriately correct the issue preventing disabled blocking directly when parsing parameters * Use the same length logic previously seen * Code reviewcomments * Remove redundant check * Revert nil check removal; Removing this broke tests --- api/api_interface_impl.go | 2 +- api/api_interface_impl_test.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/api/api_interface_impl.go b/api/api_interface_impl.go index fb1a3fba..ec1b3e95 100644 --- a/api/api_interface_impl.go +++ b/api/api_interface_impl.go @@ -103,7 +103,7 @@ func (i *OpenAPIInterfaceImpl) DisableBlocking(ctx context.Context, } } - if request.Params.Groups != nil { + if request.Params.Groups != nil && len(*request.Params.Groups) > 0 { groups = strings.Split(*request.Params.Groups, ",") } diff --git a/api/api_interface_impl_test.go b/api/api_interface_impl_test.go index a1b14138..45444395 100644 --- a/api/api_interface_impl_test.go +++ b/api/api_interface_impl_test.go @@ -218,6 +218,23 @@ var _ = Describe("API implementation tests", func() { Describe("Control blocking status via API", func() { When("Disable blocking is called", func() { + It("should return a success when receiving no groups", func() { + var emptySlice []string + blockingControlMock.On("DisableBlocking", 3*time.Second, emptySlice).Return(nil) + duration := "3s" + grroups := "" + + resp, err := sut.DisableBlocking(ctx, DisableBlockingRequestObject{ + Params: DisableBlockingParams{ + Duration: &duration, + Groups: &grroups, + }, + }) + Expect(err).Should(Succeed()) + var resp200 DisableBlocking200Response + Expect(resp).Should(BeAssignableToTypeOf(resp200)) + }) + It("should return 200 on success", func() { blockingControlMock.On("DisableBlocking", 3*time.Second, []string{"gr1", "gr2"}).Return(nil) duration := "3s"