nothing important here

Former-commit-id: e6c4ade12d085cb8fa4989b15fa446b75ee114b2
This commit is contained in:
Gerasimos (Makis) Maropoulos 2019-07-15 09:58:05 +03:00
parent 2725267aa4
commit ccafe67c80
5 changed files with 20 additions and 13 deletions

View File

@ -5,10 +5,9 @@ os:
go: go:
- 1.12.x - 1.12.x
go_import_path: github.com/kataras/iris go_import_path: github.com/kataras/iris
# we disable test caching via GOCACHE=off env:
# env: global:
# global: - GO111MODULE=on
# - GOCACHE=off
install: install:
- go get ./... - go get ./...
script: script:

View File

@ -0,0 +1,8 @@
// +build go1.9
package httptest
import "github.com/gavv/httpexpect"
// Request type alias.
type Request = httpexpect.Request

View File

@ -115,6 +115,7 @@ func formatCookieDomain(ctx context.Context, disableSubdomainPersistence bool) s
requestDomain = requestDomain[dotIdx+1:] requestDomain = requestDomain[dotIdx+1:]
} }
} }
// finally set the .localhost.com (for(1-level) || .mysubdomain.localhost.com (for 2-level subdomain allow) // finally set the .localhost.com (for(1-level) || .mysubdomain.localhost.com (for 2-level subdomain allow)
return "." + requestDomain // . to allow persistence return "." + requestDomain // . to allow persistence
} }

View File

@ -177,12 +177,12 @@ func (s *Sessions) decodeCookieValue(cookieValue string) string {
return "" return ""
} }
var cookieValueDecoded *string var cookieValueDecoded string
if decode := s.config.Decode; decode != nil { if decode := s.config.Decode; decode != nil {
err := decode(s.config.Cookie, cookieValue, &cookieValueDecoded) err := decode(s.config.Cookie, cookieValue, &cookieValueDecoded)
if err == nil { if err == nil {
cookieValue = *cookieValueDecoded cookieValue = cookieValueDecoded
} else { } else {
cookieValue = "" cookieValue = ""
} }

View File

@ -17,7 +17,7 @@ func TestSessions(t *testing.T) {
} }
const ( const (
testEnableSubdomain = false testEnableSubdomain = true
) )
func testSessions(t *testing.T, sess *sessions.Sessions, app *iris.Application) { func testSessions(t *testing.T, sess *sessions.Sessions, app *iris.Application) {
@ -35,16 +35,14 @@ func testSessions(t *testing.T, sess *sessions.Sessions, app *iris.Application)
} }
if testEnableSubdomain { if testEnableSubdomain {
app.Party("subdomain.").Get("/get", func(ctx context.Context) { app.Party("subdomain.").Get("/get", writeValues)
writeValues(ctx)
})
} }
app.Post("/set", func(ctx context.Context) { app.Post("/set", func(ctx context.Context) {
s := sess.Start(ctx) s := sess.Start(ctx)
vals := make(map[string]interface{}, 0) vals := make(map[string]interface{}, 0)
if err := ctx.ReadJSON(&vals); err != nil { if err := ctx.ReadJSON(&vals); err != nil {
t.Fatalf("Cannot readjson. Trace %s", err.Error()) t.Fatalf("Cannot read JSON. Trace %s", err.Error())
} }
for k, v := range vals { for k, v := range vals {
s.Set(k, v) s.Set(k, v)
@ -84,10 +82,11 @@ func testSessions(t *testing.T, sess *sessions.Sessions, app *iris.Application)
e.POST("/set").WithJSON(values).Expect().Status(iris.StatusOK).Cookies().NotEmpty() e.POST("/set").WithJSON(values).Expect().Status(iris.StatusOK).Cookies().NotEmpty()
e.GET("/get").Expect().Status(iris.StatusOK).JSON().Object().Equal(values) e.GET("/get").Expect().Status(iris.StatusOK).JSON().Object().Equal(values)
if testEnableSubdomain { if testEnableSubdomain {
es := httptest.New(t, app, httptest.URL("http://subdomain.example.com")) es := e.Builder(func(req *httptest.Request) {
req.WithURL("http://subdomain.example.com")
})
es.Request("GET", "/get").Expect().Status(iris.StatusOK).JSON().Object().Equal(values) es.Request("GET", "/get").Expect().Status(iris.StatusOK).JSON().Object().Equal(values)
} }
// test destroy which also clears first // test destroy which also clears first
d := e.GET("/destroy").Expect().Status(iris.StatusOK) d := e.GET("/destroy").Expect().Status(iris.StatusOK)
d.JSON().Object().Empty() d.JSON().Object().Empty()