Updating test cases

Fixes https://github.com/dexidp/dex/issues/2537

Signed-off-by: Shivansh Vij <shivanshvij@outlook.com>
This commit is contained in:
Shivansh Vij 2022-05-26 15:54:54 -04:00 committed by Shivansh Vij
parent cbf158bcc0
commit 65592d0b5a
No known key found for this signature in database
GPG key ID: 77E32CE606C64564

View file

@ -52,6 +52,7 @@ func TestHandleDeviceCode(t *testing.T) {
requestType string
scopes []string
expectedResponseCode int
expectedContentType string
expectedServerResponse string
}{
{
@ -60,6 +61,7 @@ func TestHandleDeviceCode(t *testing.T) {
requestType: "POST",
scopes: []string{"openid", "profile", "email"},
expectedResponseCode: http.StatusOK,
expectedContentType: "application/json",
},
{
testName: "Invalid request Type (GET)",
@ -67,6 +69,7 @@ func TestHandleDeviceCode(t *testing.T) {
requestType: "GET",
scopes: []string{"openid", "profile", "email"},
expectedResponseCode: http.StatusBadRequest,
expectedContentType: "application/json",
},
}
for _, tc := range tests {
@ -101,6 +104,10 @@ func TestHandleDeviceCode(t *testing.T) {
t.Errorf("Unexpected Response Type. Expected %v got %v", tc.expectedResponseCode, rr.Code)
}
if rr.Header().Get("content-type") != tc.expectedContentType {
t.Errorf("Unexpected Response Content Type. Expected %v got %v", tc.expectedContentType, rr.Header().Get("content-type"))
}
body, err := io.ReadAll(rr.Body)
if err != nil {
t.Errorf("Could read token response %v", err)