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:
- 1.12.x
go_import_path: github.com/kataras/iris
# we disable test caching via GOCACHE=off
# env:
# global:
# - GOCACHE=off
env:
global:
- GO111MODULE=on
install:
- go get ./...
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:]
}
}
// finally set the .localhost.com (for(1-level) || .mysubdomain.localhost.com (for 2-level subdomain allow)
return "." + requestDomain // . to allow persistence
}

View File

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

View File

@ -17,7 +17,7 @@ func TestSessions(t *testing.T) {
}
const (
testEnableSubdomain = false
testEnableSubdomain = true
)
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 {
app.Party("subdomain.").Get("/get", func(ctx context.Context) {
writeValues(ctx)
})
app.Party("subdomain.").Get("/get", writeValues)
}
app.Post("/set", func(ctx context.Context) {
s := sess.Start(ctx)
vals := make(map[string]interface{}, 0)
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 {
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.GET("/get").Expect().Status(iris.StatusOK).JSON().Object().Equal(values)
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)
}
// test destroy which also clears first
d := e.GET("/destroy").Expect().Status(iris.StatusOK)
d.JSON().Object().Empty()