Skip to content

Commit

Permalink
Fix Allow header checking
Browse files Browse the repository at this point in the history
Signed-off-by: ortyomka <iurin.art@gmail.com>
  • Loading branch information
ortyomka committed Jun 29, 2022
1 parent 6b43d1c commit ec17a4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion middleware/cors_test.go
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"net/http"
"net/http/httptest"
"strings"
"testing"

"github.com/labstack/echo/v4"
Expand Down Expand Up @@ -458,7 +459,9 @@ func TestCorsHeaders(t *testing.T) {
e.ServeHTTP(rec, req)

assert.Equal(t, echo.HeaderOrigin, rec.Header().Get(echo.HeaderVary))
assert.Equal(t, tc.expectAllowHeader, rec.Header().Get(echo.HeaderAllow))
assert.ElementsMatch(t,
strings.Split(tc.expectAllowHeader, ","),
strings.Split(rec.Header().Get(echo.HeaderAllow), ","))
assert.Equal(t, tc.expectStatus, rec.Code)

expectedAllowOrigin := ""
Expand Down
10 changes: 6 additions & 4 deletions router_test.go
Expand Up @@ -780,7 +780,9 @@ func TestMethodNotAllowedAndNotFound(t *testing.T) {
}
checkUnusedParamValues(t, c, tc.expectParam)

assert.Equal(t, tc.expectAllowHeader, c.Response().Header().Get(HeaderAllow))
assert.ElementsMatch(t,
strings.Split(tc.expectAllowHeader, ","),
strings.Split(c.Response().Header().Get(HeaderAllow), ","))
})
}
}
Expand Down Expand Up @@ -2380,9 +2382,9 @@ func TestRouterHandleMethodOptions(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, tc.expectStatus, rec.Code)
}
expect := strings.Split(tc.expectAllowHeader, ",")
actual := strings.Split(c.Response().Header().Get("Allow"), ",")
assert.ElementsMatch(t, expect, actual)
assert.ElementsMatch(t,
strings.Split(tc.expectAllowHeader, ","),
strings.Split(c.Response().Header().Get(HeaderAllow), ","))
})
}
}
Expand Down

0 comments on commit ec17a4a

Please sign in to comment.