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
This commit is contained in:
Ben 2024-02-10 12:06:01 -06:00 committed by GitHub
parent 9f633f18d0
commit fe84ab8ca2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -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, ",")
}

View File

@ -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"