2020-06-14 14:24:42 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/kataras/iris/v12/httptest"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMVCOverlapping(t *testing.T) {
|
|
|
|
app := newApp()
|
|
|
|
|
|
|
|
e := httptest.New(t, app, httptest.URL("http://example.com"))
|
|
|
|
// unauthenticated.
|
2023-07-08 01:08:18 +02:00
|
|
|
e.GET("/user").Expect().Status(httptest.StatusOK).Body().IsEqual("custom action to redirect on authentication page")
|
2020-06-14 14:24:42 +02:00
|
|
|
// login.
|
|
|
|
e.POST("/user/login").Expect().Status(httptest.StatusOK)
|
|
|
|
// authenticated.
|
2023-07-08 01:08:18 +02:00
|
|
|
e.GET("/user").Expect().Status(httptest.StatusOK).Body().IsEqual(`UserController.Get: The Authenticated type
|
2020-06-14 14:24:42 +02:00
|
|
|
can be used to secure a controller's method too.`)
|
|
|
|
// logout.
|
|
|
|
e.POST("/user/logout").Expect().Status(httptest.StatusOK)
|
|
|
|
// unauthenticated.
|
2023-07-08 01:08:18 +02:00
|
|
|
e.GET("/user").Expect().Status(httptest.StatusOK).Body().IsEqual("custom action to redirect on authentication page")
|
2020-06-14 14:24:42 +02:00
|
|
|
}
|