-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add consumer e2e test for manager-api #830
Conversation
Codecov Report
@@ Coverage Diff @@
## v2.0 #830 +/- ##
==========================================
- Coverage 42.64% 42.56% -0.08%
==========================================
Files 18 18
Lines 1257 1257
==========================================
- Hits 536 535 -1
- Misses 630 631 +1
Partials 91 91
Continue to review full report at Codecov.
|
api/test/e2e/consumer_test.go
Outdated
Path: "/hello", | ||
Headers: map[string]string{"apikey": "auth-one"}, | ||
ExpectStatus: http.StatusOK, | ||
Sleep: sleepTime, //sleep x millisecond before verify route |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to check body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to check before consumer created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, thanks for the suggestion, I already add it now.
add new case about update consumer
"username":"case_8", | ||
"desc": "new consumer" | ||
}` | ||
request, _ := http.NewRequest("PUT", "http://127.0.0.1:8080/apisix/admin/consumers", strings.NewReader(data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to extract public variables? such as BASE_URL = http://127.0.0.1:8080/apisix/admin/consumers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can close this PR, split this big PR to smaller ones
api/test/e2e/consumer_test.go
Outdated
"github.com/tidwall/gjson" | ||
) | ||
|
||
//case 1: add consumer with username |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove useless code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and pls remove other similar points
ExpectStatus: http.StatusOK, | ||
}, | ||
{ | ||
caseDesc: "verify route", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desc: hit route with correct key
Sleep: sleepTime, | ||
}, | ||
{ | ||
caseDesc: "verify route", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desc: hit route with incorrect key
ExpectStatus: http.StatusUnauthorized, | ||
ExpectBody: "Invalid API key in request", | ||
Sleep: sleepTime, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to delete the consumer
and check it in dataplane
func TestConsumer_add_consumer_without_username(t *testing.T) { | ||
tests := []HttpTestCase{ | ||
{ | ||
caseDesc: "create consumer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad title.
create consumer without user name
ExpectStatus: http.StatusBadRequest, | ||
}, | ||
{ | ||
caseDesc: "verify route", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to create the route
first
Please answer these questions before submitting a pull request
Why submit this pull request?
add consumer e2e test for manager-api
Depend on issues [refactor][bug] bind params to struct error should response error with 400 status #568 #870 bug: manager-api supported
POST
method for consumer #852Related issues
proposal: e2e test #607