mirror of https://github.com/0xERR0R/blocky.git
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:
parent
9f633f18d0
commit
fe84ab8ca2
|
@ -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, ",")
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue