1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00

update mvc/authenticated-controller example

rel to: https://github.com/kataras/iris/issues/1536 too


Former-commit-id: 0ed36644ee2d6c27d90450700d9241eb1ba93c17
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-06-14 15:24:42 +03:00
parent 9c739969f0
commit 5088a35cf5
4 changed files with 56 additions and 41 deletions

View File

@@ -0,0 +1,24 @@
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.
e.GET("/user").Expect().Status(httptest.StatusOK).Body().Equal("custom action to redirect on authentication page")
// login.
e.POST("/user/login").Expect().Status(httptest.StatusOK)
// authenticated.
e.GET("/user").Expect().Status(httptest.StatusOK).Body().Equal(`UserController.Get: The Authenticated type
can be used to secure a controller's method too.`)
// logout.
e.POST("/user/logout").Expect().Status(httptest.StatusOK)
// unauthenticated.
e.GET("/user").Expect().Status(httptest.StatusOK).Body().Equal("custom action to redirect on authentication page")
}