This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/next by this push:
new ece25548 feat: move label unit cases to e2e (#2513)
ece25548 is described below
commit ece2554811bfd0db532973996a63e879e946ee24
Author: Zeping Bai <[email protected]>
AuthorDate: Tue Jul 12 17:11:21 2022 +0800
feat: move label unit cases to e2e (#2513)
---
api/internal/handler/label/label_test.go | 377 ----------------------
api/test/e2e/label/label_test.go | 522 +++++++++++++++----------------
2 files changed, 260 insertions(+), 639 deletions(-)
diff --git a/api/internal/handler/label/label_test.go
b/api/internal/handler/label/label_test.go
deleted file mode 100644
index 6136ebb7..00000000
--- a/api/internal/handler/label/label_test.go
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package label
-
-import (
- "encoding/json"
- "math/rand"
- "testing"
-
- "github.com/shiningrush/droplet"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/mock"
-
- "github.com/apache/apisix-dashboard/api/internal/core/entity"
- "github.com/apache/apisix-dashboard/api/internal/core/store"
-)
-
-type testCase struct {
- giveInput *ListInput
- giveData []interface{}
- wantRet interface{}
-}
-
-func TestPair_MarshalJSON(t *testing.T) {
- type tempStruct struct {
- Val string `json:"test_key"`
- }
-
- temp := tempStruct{Val: "test_val"}
- expect, err := json.Marshal(temp)
- assert.Nil(t, err)
-
- p := Pair{Key: "test_key", Val: `test_val`}
- content, err := json.Marshal(p)
- assert.Nil(t, err, nil)
- assert.Equal(t, expect, content)
-
- mp := make(map[string]string)
- err = json.Unmarshal(content, &mp)
- assert.Nil(t, err)
- assert.Equal(t, mp["test_key"], "test_val")
-
- // Because the quote in json key is not allowed.
- // So we only test the quote in json value.
- temp = tempStruct{Val: "test_val\""}
- expect, err = json.Marshal(temp)
- assert.Nil(t, err)
-
- p = Pair{Key: "test_key", Val: `test_val"`}
- content, err = json.Marshal(p)
- assert.Nil(t, err, nil)
- assert.Equal(t, expect, content)
-
- mp = make(map[string]string)
- err = json.Unmarshal(content, &mp)
- assert.Nil(t, err)
- assert.Equal(t, mp["test_key"], "test_val\"")
-}
-
-func genMockStore(t *testing.T, giveData []interface{}) *store.MockInterface {
- mStore := &store.MockInterface{}
- mStore.On("List", mock.Anything).Run(func(args mock.Arguments) {
- input := args.Get(0).(store.ListInput)
- assert.Equal(t, 0, input.PageSize)
- assert.Equal(t, 0, input.PageNumber)
- }).Return(func(input store.ListInput) *store.ListOutput {
- var returnData []interface{}
- for _, c := range giveData {
- if input.Predicate(c) {
- returnData = append(returnData, input.Format(c))
- }
- }
- return &store.ListOutput{
- Rows: returnData,
- TotalSize: len(returnData),
- }
- }, nil)
-
- return mStore
-}
-
-func newCase(giveData []interface{}, ret []interface{}) *testCase {
- t := testCase{}
- t.giveInput = &ListInput{
- Pagination: store.Pagination{
- PageSize: 10,
- PageNumber: 1,
- },
- }
-
- t.giveData = giveData
- t.wantRet = &store.ListOutput{
- Rows: ret,
- TotalSize: len(ret),
- }
-
- return &t
-}
-
-func genRoute(labels map[string]string) *entity.Route {
- r := entity.Route{
- BaseInfo: entity.BaseInfo{
- ID: rand.Int(),
- CreateTime: rand.Int63(),
- },
- Host: "test.com",
- URI: "/test/route",
- Labels: labels,
- }
-
- return &r
-}
-
-func genService(labels map[string]string) *entity.Service {
- r := entity.Service{
- BaseInfo: entity.BaseInfo{
- ID: rand.Int(),
- CreateTime: rand.Int63(),
- },
- EnableWebsocket: true,
- Labels: labels,
- }
-
- return &r
-}
-
-func genSSL(labels map[string]string) *entity.SSL {
- r := entity.SSL{
- BaseInfo: entity.BaseInfo{
- ID: rand.Int(),
- CreateTime: rand.Int63(),
- },
- Labels: labels,
- }
-
- return &r
-}
-
-func genUpstream(labels map[string]string) *entity.Upstream {
- r := entity.Upstream{
- BaseInfo: entity.BaseInfo{
- ID: rand.Int(),
- CreateTime: rand.Int63(),
- },
- UpstreamDef: entity.UpstreamDef{
- Labels: labels,
- },
- }
-
- return &r
-}
-
-func genConsumer(labels map[string]string) *entity.Consumer {
- r := entity.Consumer{
- Username: "test",
- Labels: labels,
- }
-
- return &r
-}
-
-func genPluginConfig(labels map[string]string) *entity.PluginConfig {
- r := entity.PluginConfig{
- BaseInfo: entity.BaseInfo{
- ID: rand.Int(),
- CreateTime: rand.Int63(),
- },
- Labels: labels,
- }
-
- return &r
-}
-
-func TestLabel(t *testing.T) {
- m1 := map[string]string{
- "label1": "value1",
- "label2": "value2",
- }
-
- m2 := map[string]string{
- "label1": "value2",
- }
-
- // TODO: Test SSL after the ssl config bug fixed
- types := []string{"route", "service", "upstream", "consumer",
"plugin_config"}
-
- var giveData []interface{}
- for _, typ := range types {
- switch typ {
- case "route":
- giveData = []interface{}{
- genRoute(m1),
- genRoute(m2),
- }
- case "service":
- giveData = []interface{}{
- genService(m1),
- genService(m2),
- }
- case "ssl":
- giveData = []interface{}{
- genSSL(m1),
- genSSL(m2),
- }
- case "upstream":
- giveData = []interface{}{
- genUpstream(m1),
- genUpstream(m2),
- }
- case "consumer":
- giveData = []interface{}{
- genConsumer(m1),
- genConsumer(m2),
- }
- case "plugin_config":
- giveData = []interface{}{
- genPluginConfig(m1),
- genPluginConfig(m2),
- }
- }
-
- var testCases []*testCase
-
- expect := []interface{}{
- Pair{"label1", "value1"},
- Pair{"label1", "value2"},
- Pair{"label2", "value2"},
- }
- tc := newCase(giveData, expect)
- tc.giveInput.Type = typ
- testCases = append(testCases, tc)
-
- expect = []interface{}{
- Pair{"label1", "value1"},
- Pair{"label1", "value2"},
- }
- tc = newCase(giveData, expect)
- tc.giveInput.Type = typ
- tc.giveInput.Label = "label1"
- testCases = append(testCases, tc)
-
- expect = []interface{}{
- Pair{"label1", "value2"},
- }
- tc = newCase(giveData, expect)
- tc.giveInput.Type = typ
- tc.giveInput.Label = "label1:value2"
- testCases = append(testCases, tc)
-
- expect = []interface{}{
- Pair{"label1", "value1"},
- Pair{"label1", "value2"},
- }
- tc = newCase(giveData, expect)
- tc.giveInput.Type = typ
- tc.giveInput.Label = "label1:value1,label1:value2"
- testCases = append(testCases, tc)
-
- handler := Handler{}
- for _, tc := range testCases {
- switch typ {
- case "route":
- handler.routeStore = genMockStore(t,
tc.giveData)
- case "service":
- handler.serviceStore = genMockStore(t,
tc.giveData)
- case "ssl":
- handler.sslStore = genMockStore(t, tc.giveData)
- case "upstream":
- handler.upstreamStore = genMockStore(t,
tc.giveData)
- case "consumer":
- handler.consumerStore = genMockStore(t,
tc.giveData)
- case "plugin_config":
- handler.pluginConfigStore = genMockStore(t,
tc.giveData)
- }
-
- ctx := droplet.NewContext()
- ctx.SetInput(tc.giveInput)
- ret, err := handler.List(ctx)
- assert.Nil(t, err)
- assert.Equal(t, tc.wantRet, ret)
- }
- }
-
- // test all
- m3 := map[string]string{
- "label3": "value3",
- }
-
- m4 := map[string]string{
- "label4": "value4",
- }
-
- m5 := map[string]string{
- "label4": "value4",
- "label5": "value5",
- }
-
- handler := Handler{
- routeStore: genMockStore(t, []interface{}{genRoute(m1)}),
- sslStore: genMockStore(t, []interface{}{genSSL(m2)}),
- upstreamStore: genMockStore(t,
[]interface{}{genUpstream(m3)}),
- consumerStore: genMockStore(t,
[]interface{}{genConsumer(m4)}),
- serviceStore: genMockStore(t,
[]interface{}{genService(m5)}),
- pluginConfigStore: genMockStore(t,
[]interface{}{genPluginConfig(m5)}),
- }
-
- var testCases []*testCase
-
- expect := []interface{}{
- Pair{"label1", "value1"},
- Pair{"label1", "value2"},
- Pair{"label2", "value2"},
- Pair{"label3", "value3"},
- Pair{"label4", "value4"},
- Pair{"label5", "value5"},
- }
- tc := newCase(nil, expect)
- tc.giveInput.Type = "all"
- testCases = append(testCases, tc)
-
- expect = []interface{}{
- Pair{"label1", "value1"},
- Pair{"label1", "value2"},
- }
- tc = newCase(nil, expect)
- tc.giveInput.Type = "all"
- tc.giveInput.Label = "label1"
- testCases = append(testCases, tc)
-
- expect = []interface{}{
- Pair{"label1", "value2"},
- }
- tc = newCase(nil, expect)
- tc.giveInput.Type = "all"
- tc.giveInput.Label = "label1:value2"
- testCases = append(testCases, tc)
-
- expect = []interface{}{
- Pair{"label1", "value1"},
- Pair{"label1", "value2"},
- Pair{"label5", "value5"},
- }
- tc = newCase(nil, expect)
- tc.giveInput.Type = "all"
- tc.giveInput.Label = "label1,label5:value5"
-
- expect = []interface{}{
- Pair{"label1", "value1"},
- Pair{"label1", "value2"},
- }
- tc = newCase(nil, expect)
- tc.giveInput.Type = "all"
- tc.giveInput.Label = "label1=value1,label1=value2"
-
- for _, tc := range testCases {
- ctx := droplet.NewContext()
- ctx.SetInput(tc.giveInput)
- ret, err := handler.List(ctx)
- assert.Nil(t, err)
- assert.Equal(t, tc.wantRet, ret)
- }
-}
diff --git a/api/test/e2e/label/label_test.go b/api/test/e2e/label/label_test.go
index 9634ff16..416518b3 100644
--- a/api/test/e2e/label/label_test.go
+++ b/api/test/e2e/label/label_test.go
@@ -19,19 +19,18 @@ package label
import (
"net/http"
- "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo"
"github.com/apache/apisix-dashboard/api/test/e2e/base"
)
-var _ = ginkgo.Describe("Test label", func() {
- ginkgo.Context("test label", func() {
- ginkgo.It("config route", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Path: "/apisix/admin/routes/r1",
- Method: http.MethodPut,
- Body: `{
+var _ = Describe("Test label", func() {
+ It("Create route", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Path: "/apisix/admin/routes/r1",
+ Method: http.MethodPut,
+ Body: `{
"name": "route1",
"uri": "/hello",
"labels": {
@@ -48,16 +47,16 @@ var _ = ginkgo.Describe("Test label", func() {
}]
}
}`,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("create consumer", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Path: "/apisix/admin/consumers/c1",
- Method: http.MethodPut,
- Body: `{
+ })
+ It("Create consumer", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Path: "/apisix/admin/consumers/c1",
+ Method: http.MethodPut,
+ Body: `{
"username": "c1",
"plugins": {
"key-auth": {
@@ -71,16 +70,16 @@ var _ = ginkgo.Describe("Test label", func() {
},
"desc": "test description"
}`,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("create upstream", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodPut,
- Path: "/apisix/admin/upstreams/u1",
- Body: `{
+ })
+ It("Create upstream", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/u1",
+ Body: `{
"nodes": [{
"host": "` + base.UpstreamIp +
`",
"port": 1980,
@@ -93,16 +92,16 @@ var _ = ginkgo.Describe("Test label", func() {
},
"type": "roundrobin"
}`,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("create service", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodPost,
- Path: "/apisix/admin/services",
- Body: `{
+ })
+ It("Create service", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPost,
+ Path: "/apisix/admin/services",
+ Body: `{
"id": "s1",
"plugins": {
"limit-count": {
@@ -128,16 +127,16 @@ var _ = ginkgo.Describe("Test label", func() {
"extra": "test"
}
}`,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("create plugin_config", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodPut,
- Path: "/apisix/admin/plugin_configs/1",
- Body: `{
+ })
+ It("Create plugin config", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/plugin_configs/1",
+ Body: `{
"plugins": {
"response-rewrite": {
"headers": {
@@ -151,67 +150,67 @@ var _ = ginkgo.Describe("Test label", func() {
"extra": "test"
}
}`,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("get route label", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Path: "/apisix/admin/labels/route",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"env\":\"production\"},{\"version\":\"v2\"}",
- Sleep: base.SleepTime,
- })
+ })
+ It("Get route label", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Path: "/apisix/admin/labels/route",
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
`{"build":"16"},{"env":"production"},{"version":"v2"}`,
+ Sleep: base.SleepTime,
})
- ginkgo.It("get consumer label", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Path: "/apisix/admin/labels/consumer",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"env\":\"production\"},{\"version\":\"v3\"}",
- })
+ })
+ It("Get consumer label", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Path: "/apisix/admin/labels/consumer",
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
`{"build":"16"},{"env":"production"},{"version":"v3"}`,
})
- ginkgo.It("get upstream label", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Path: "/apisix/admin/labels/upstream",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"17\"},{\"env\":\"production\"},{\"version\":\"v2\"}",
- })
+ })
+ It("Get upstream label", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Path: "/apisix/admin/labels/upstream",
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
`{"build":"17"},{"env":"production"},{"version":"v2"}`,
})
- ginkgo.It("get service label", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Path: "/apisix/admin/labels/service",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"env\":\"production\"},{\"extra\":\"test\"},{\"version\":\"v2\"}",
- })
+ })
+ It("Get service label", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Path: "/apisix/admin/labels/service",
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
`{"build":"16"},{"env":"production"},{"extra":"test"},{"version":"v2"}`,
})
- ginkgo.It("get plugin_config label", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Path:
"/apisix/admin/labels/plugin_config",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"17\"},{\"extra\":\"test\"},{\"version\":\"v2\"}",
- })
+ })
+ It("Get plugin config label", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Path: "/apisix/admin/labels/plugin_config",
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
`{"build":"17"},{"extra":"test"},{"version":"v2"}`,
})
- ginkgo.It("update plugin_config", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodPut,
- Path: "/apisix/admin/plugin_configs/1",
- Body: `{
+ })
+ It("Update plugin config", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/plugin_configs/1",
+ Body: `{
"plugins": {
"response-rewrite": {
"headers": {
@@ -225,185 +224,184 @@ var _ = ginkgo.Describe("Test label", func() {
"extra": "test"
}
}`,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("get plugin_config label again to verify update",
func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Path:
"/apisix/admin/labels/plugin_config",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"extra\":\"test\"},{\"version\":\"v3\"}",
- Sleep: base.SleepTime,
- })
+ })
+ It("Get plugin config (Updated)", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Path: "/apisix/admin/labels/plugin_config",
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
`{"build":"16"},{"extra":"test"},{"version":"v3"}`,
+ Sleep: base.SleepTime,
})
- ginkgo.It("get all label", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"build\":\"17\"},{\"env\":\"production\"},{\"extra\":\"test\"},{\"version\":\"v2\"},{\"version\":\"v3\"}",
- })
+ })
+ It("List label", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
`{"build":"16"},{"build":"17"},{"env":"production"},{"extra":"test"},{"version":"v2"},{"version":"v3"}`,
})
- ginkgo.It("get label with page", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Query: "page=1&page_size=1",
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody: "{\"build\":\"16\"}",
- })
+ })
+ It("List label (Paginate) #1", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Query: "page=1&page_size=1",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: `{"build":"16"}`,
})
- ginkgo.It("get label with page", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Query: "page=3&page_size=1",
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody: "{\"env\":\"production\"}",
- })
+ })
+ It("List label (Paginate) #2", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Query: "page=3&page_size=1",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: `{"env":"production"}`,
})
- ginkgo.It("get labels (key = build)", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Query: "label=build",
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"build\":\"17\"}",
- })
+ })
+ It("Get labels (With condition, key = build)", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Query: "label=build",
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: `{"build":"16"},{"build":"17"}`,
})
- ginkgo.It("get labels with the same key (key = build)", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Query: "label=build:16,build:17",
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"build\":\"17\"}",
- })
+ })
+ It("Get labels with the same key (With condition, key = build)", func()
{
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Query: "label=build:16,build:17",
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: `{"build":"16"},{"build":"17"}`,
})
- ginkgo.It("get labels (key = build) with page", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Query: "label=build&page=2&page_size=1",
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody: "{\"build\":\"17\"}",
- })
+ })
+ It("Get labels (With condition, key = build; Paginate)", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Query: "label=build&page=2&page_size=1",
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: `{"build":"17"}`,
})
- ginkgo.It("get labels with same key (key = build) and page",
func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Query:
"label=build:16,build:17&page=1&page_size=2",
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"build\":\"17\"}",
- })
+ })
+ It("Get labels with same key (With condition, key = build; Paginate)",
func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Query:
"label=build:16,build:17&page=1&page_size=2",
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: `{"build":"16"},{"build":"17"}`,
})
- ginkgo.It("get labels with same key (key = build) and page",
func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Query:
"label=build:16,build:17&page=2&page_size=1",
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody: "{\"build\":\"17\"}",
- })
+ })
+ It("Get labels with same key (With condition, key = build; Paginate)",
func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Query:
"label=build:16,build:17&page=2&page_size=1",
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: `{"build":"17"}`,
})
- ginkgo.It("get labels (key = build && env = production)",
func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Query: "label=build,env:production",
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"build\":\"17\"},{\"env\":\"production\"}",
- })
+ })
+ It("Get labels (With condition, key = build && env = production)",
func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Query: "label=build,env:production",
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
`{"build":"16"},{"build":"17"},{"env":"production"}`,
})
- ginkgo.It("get labels (build=16 | 17 and env = production)",
func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Query:
"label=build:16,build:17,env:production",
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody:
"{\"build\":\"16\"},{\"build\":\"17\"},{\"env\":\"production\"}",
- })
+ })
+ It("Get labels (With condition, build=16|17 && env = production)",
func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Query: "label=build:16,build:17,env:production",
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
`{"build":"16"},{"build":"17"},{"env":"production"}`,
})
- ginkgo.It("get labels (key = build && env = production) with
page", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodGet,
- Headers:
map[string]string{"Authorization": base.GetToken()},
- Query:
"label=build,env:production&page=3&page_size=1",
- Path: "/apisix/admin/labels/all",
- ExpectStatus: http.StatusOK,
- ExpectBody: "{\"env\":\"production\"}",
- })
+ })
+ It("Get labels (With condition, key = build && env = production;
Paginate)", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ Query:
"label=build,env:production&page=3&page_size=1",
+ Path: "/apisix/admin/labels/all",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: `{"env":"production"}`,
})
- ginkgo.It("delete route", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodDelete,
- Path: "/apisix/admin/routes/r1",
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ })
+ It("Delete route", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("delete consumer", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodDelete,
- Path: "/apisix/admin/consumers/c1",
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ })
+ It("Delete consumer", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/consumers/c1",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("delete service", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodDelete,
- Path: "/apisix/admin/services/s1",
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ })
+ It("Delete service", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/services/s1",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("delete upstream", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodDelete,
- Path: "/apisix/admin/upstreams/u1",
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ })
+ It("Delete upstream", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/upstreams/u1",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
- ginkgo.It("delete plugin_config", func() {
- base.RunTestCase(base.HttpTestCase{
- Object: base.ManagerApiExpect(),
- Method: http.MethodDelete,
- Path: "/apisix/admin/plugin_configs/1",
- Headers:
map[string]string{"Authorization": base.GetToken()},
- ExpectStatus: http.StatusOK,
- })
+ })
+ It("Delete plugin config", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/plugin_configs/1",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
})
})
})