1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-29 07:47:22 +00:00

Happy new year! Update to 6.0.0 | HTTP/2 full support. https://github.com/kataras/iris/issues/565

full commit from development branch.

Examples, book, middleware, plugins are updated to the latest iris
version. Read HISTORY.md for more.

The 'old' v5 branch which relied on fasthttp exists for those who want
to use it navigate there: https://github.com/kataras/iris/tree/5.0.0
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-01-02 21:20:17 +02:00
parent ced2083ab3
commit 8bbd9f8fc5
25 changed files with 2067 additions and 2213 deletions

View File

@@ -3,70 +3,69 @@ package iris_test
import (
"fmt"
"github.com/gavv/httpexpect"
"github.com/kataras/go-errors"
"github.com/kataras/iris"
"github.com/kataras/iris/httptest"
"github.com/valyala/fasthttp"
"io/ioutil"
"math/rand"
"net/http"
"os"
"strconv"
"sync/atomic"
"testing"
"time"
"github.com/gavv/httpexpect"
"github.com/kataras/iris"
"github.com/kataras/iris/httptest"
)
const (
testTLSCert = `-----BEGIN CERTIFICATE-----
MIIDATCCAemgAwIBAgIJAPdE0ZyCKwVtMA0GCSqGSIb3DQEBBQUAMBcxFTATBgNV
BAMMDG15ZG9tYWluLmNvbTAeFw0xNjA5MjQwNjU3MDVaFw0yNjA5MjIwNjU3MDVa
MBcxFTATBgNVBAMMDG15ZG9tYWluLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBAM9YJOV1Bl+NwEq8ZAcVU2YONBw5zGkUFJUZkL77XT0i1V473JTf
GEpNZisDman+6n+pXarC2mR4T9PkCfmk072HaZ2LXwYe9XSgxnLJZJA1fJMzdMMC
2XveINF+/eeoyW9+8ZjQPbZdHWcxi7RomXg1AOMAG2UWMjalK5xkTHcqDuOI2LEe
mezWHnFdBJNMTi3pNdbVr7BjexZTSGhx4LAIP2ufTUoVzk+Cvyr4IhS00zOiyyWv
tuJaO20Q0Q5n34o9vDAACKAfNRLBE8qzdRwsjMumXTX3hJzvgFp/4Lr5Hr2I2fBd
tbIWN9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pkaxv25bPYwUSEB7lPa+hBtRyN9Wo6qfAoGAPBkeISiU1hJE0i7YW55h
FZfKZoqSYq043B+ywo+1/Dsf+UH0VKM1ZSAnZPpoVc/hyaoW9tAb98r0iZ620wJl
VkCjgYklknbY5APmw/8SIcxP6iVq1kzQqDYjcXIRVa3rEyWEcLzM8VzL8KFXbIQC
lPIRHFfqKuMEt+HLRTXmJ7MCgYAHGvv4QjdmVl7uObqlG9DMGj1RjlAF0VxNf58q
NrLmVG2N2qV86wigg4wtZ6te4TdINfUcPkmQLYpLz8yx5Z2bsdq5OPP+CidoD5nC
WqnSTIKGR2uhQycjmLqL5a7WHaJsEFTqHh2wego1k+5kCUzC/KmvM7MKmkl6ICp+
3qZLUwKBgQCDOhKDwYo1hdiXoOOQqg/LZmpWOqjO3b4p99B9iJqhmXN0GKXIPSBh
5nqqmGsG8asSQhchs7EPMh8B80KbrDTeidWskZuUoQV27Al1UEmL6Zcl83qXD6sf
k9X9TwWyZtp5IL1CAEd/Il9ZTXFzr3lNaN8LCFnU+EIsz1YgUW8LTg==
-----END RSA PRIVATE KEY-----
`
`
)
func TestParseAddr(t *testing.T) {
@@ -155,7 +154,7 @@ func getRandomNumber(min int, max int) int {
// works as
// defer listenTLS(iris.Default, hostTLS)()
func listenTLS(api *iris.Framework, hostTLS string) func() {
api.Close() // close any previous server
api.Close() // close any prev listener
api.Config.DisableBanner = true
// create the key and cert files on the fly, and delete them when this test finished
certFile, ferr := ioutil.TempFile("", "cert")
@@ -179,68 +178,77 @@ func listenTLS(api *iris.Framework, hostTLS string) func() {
return func() {
certFile.Close()
time.Sleep(150 * time.Millisecond)
time.Sleep(50 * time.Millisecond)
os.Remove(certFile.Name())
keyFile.Close()
time.Sleep(150 * time.Millisecond)
time.Sleep(50 * time.Millisecond)
os.Remove(keyFile.Name())
api.Close()
}
}
// Contains the server test for multi running servers
func TestMultiRunningServers_v1_PROXY(t *testing.T) {
iris.ResetDefault()
api := iris.New()
host := "localhost" // you have to add it to your hosts file( for windows, as 127.0.0.1 mydomain.com)
hostTLS := host + ":" + strconv.Itoa(getRandomNumber(8886, 8889))
iris.Get("/", func(ctx *iris.Context) {
ctx.Write("Hello from %s", hostTLS)
host := "localhost"
hostTLS := host + ":" + strconv.Itoa(getRandomNumber(1919, 2221))
api.Get("/", func(ctx *iris.Context) {
ctx.Writef("Hello from %s", hostTLS)
})
// println("running main on: " + hostTLS)
proxyHost := host + ":" + strconv.Itoa(getRandomNumber(3300, 3332))
closeProxy := iris.Proxy(proxyHost, "https://"+hostTLS)
defer closeProxy()
defer listenTLS(api, hostTLS)()
defer listenTLS(iris.Default, hostTLS)()
e := httptest.New(api, t, httptest.ExplicitURL(true))
e.Request("GET", "/").Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
e := httptest.New(iris.Default, t, httptest.ExplicitURL(true))
// proxy http to https
proxyHost := host + ":" + strconv.Itoa(getRandomNumber(3300, 3340))
// println("running proxy on: " + proxyHost)
e.Request("GET", "http://"+proxyHost).Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
e.Request("GET", "https://"+hostTLS).Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
iris.Proxy(proxyHost, "https://"+hostTLS)
// proxySrv := &http.Server{Addr: proxyHost, Handler: iris.ProxyHandler("https://" + hostTLS)}
// go proxySrv.ListenAndServe()
// time.Sleep(3 * time.Second)
eproxy := httptest.NewInsecure("http://"+proxyHost, t, httptest.ExplicitURL(true))
eproxy.Request("GET", "/").Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
}
// Contains the server test for multi running servers
func TestMultiRunningServers_v2(t *testing.T) {
iris.ResetDefault()
api := iris.New()
domain := "localhost"
hostTLS := domain + ":" + strconv.Itoa(getRandomNumber(3333, 4444))
hostTLS := domain + ":" + strconv.Itoa(getRandomNumber(2222, 2229))
srv1Host := domain + ":" + strconv.Itoa(getRandomNumber(4446, 5444))
srv2Host := domain + ":" + strconv.Itoa(getRandomNumber(7778, 8887))
iris.Get("/", func(ctx *iris.Context) {
ctx.Write("Hello from %s", hostTLS)
api.Get("/", func(ctx *iris.Context) {
ctx.Writef("Hello from %s", hostTLS)
})
// using the proxy handler
fsrv1 := &fasthttp.Server{Handler: iris.ProxyHandler(srv1Host, "https://"+hostTLS)}
go fsrv1.ListenAndServe(srv1Host)
defer listenTLS(api, hostTLS)()
// using the same iris' handler but not as proxy, just the same handler
fsrv2 := &fasthttp.Server{Handler: iris.Default.Router}
go fsrv2.ListenAndServe(srv2Host)
srv2 := &http.Server{Handler: api.Router, Addr: srv2Host}
go srv2.ListenAndServe()
defer listenTLS(iris.Default, hostTLS)()
// using the proxy handler
srv1 := &http.Server{Handler: iris.ProxyHandler("https://" + hostTLS), Addr: srv1Host}
go srv1.ListenAndServe()
time.Sleep(500 * time.Millisecond) // wait a little for the http servers
e := httptest.New(iris.Default, t, httptest.ExplicitURL(true))
e := httptest.New(api, t, httptest.ExplicitURL(true))
e.Request("GET", "/").Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
e.Request("GET", "http://"+srv1Host).Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
e.Request("GET", "http://"+srv2Host).Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
e.Request("GET", "https://"+hostTLS).Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
eproxy1 := httptest.NewInsecure("http://"+srv1Host, t, httptest.ExplicitURL(true))
eproxy1.Request("GET", "/").Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
eproxy2 := httptest.NewInsecure("http://"+srv2Host, t)
eproxy2.Request("GET", "/").Expect().Status(iris.StatusOK).Body().Equal("Hello from " + hostTLS)
}
@@ -360,7 +368,7 @@ func TestMuxSimple(t *testing.T) {
func TestMuxSimpleParty(t *testing.T) {
iris.ResetDefault()
h := func(c *iris.Context) { c.WriteString(c.HostString() + c.PathString()) }
h := func(c *iris.Context) { c.WriteString(c.Request.URL.Host + c.Request.RequestURI) }
if testEnableSubdomain {
subdomainParty := iris.Party(testSubdomain + ".")
@@ -422,8 +430,9 @@ func TestMuxPathEscape(t *testing.T) {
iris.ResetDefault()
iris.Get("/details/:name", func(ctx *iris.Context) {
name := ctx.Param("name")
name := ctx.ParamDecoded("name")
highlight := ctx.URLParam("highlight")
ctx.Text(iris.StatusOK, fmt.Sprintf("name=%s,highlight=%s", name, highlight))
})
@@ -438,9 +447,10 @@ func TestMuxDecodeURL(t *testing.T) {
iris.ResetDefault()
iris.Get("/encoding/:url", func(ctx *iris.Context) {
url := iris.DecodeURL(ctx.Param("url"))
url := ctx.ParamDecoded("url")
ctx.SetStatusCode(iris.StatusOK)
ctx.Write(url)
ctx.WriteString(url)
})
e := httptest.New(iris.Default, t)
@@ -487,11 +497,11 @@ func TestMuxCustomErrors(t *testing.T) {
// register the custom errors
iris.OnError(iris.StatusNotFound, func(ctx *iris.Context) {
ctx.Write("%s", notFoundMessage)
ctx.Writef("%s", notFoundMessage)
})
iris.OnError(iris.StatusInternalServerError, func(ctx *iris.Context) {
ctx.Write("%s", internalServerMessage)
ctx.Writef("%s", internalServerMessage)
})
// create httpexpect instance that will call fasthtpp.RequestHandler directly
@@ -511,27 +521,27 @@ type testUserAPI struct {
// GET /users
func (u testUserAPI) Get() {
u.Write("Get Users\n")
u.WriteString("Get Users\n")
}
// GET /users/:param1 which its value passed to the id argument
func (u testUserAPI) GetBy(id string) { // id equals to u.Param("param1")
u.Write("Get By %s\n", id)
u.Writef("Get By %s\n", id)
}
// PUT /users
func (u testUserAPI) Put() {
u.Write("Put, name: %s\n", u.FormValue("name"))
u.Writef("Put, name: %s\n", u.FormValue("name"))
}
// POST /users/:param1
func (u testUserAPI) PostBy(id string) {
u.Write("Post By %s, name: %s\n", id, u.FormValue("name"))
u.Writef("Post By %s, name: %s\n", id, u.FormValue("name"))
}
// DELETE /users/:param1
func (u testUserAPI) DeleteBy(id string) {
u.Write("Delete By %s\n", id)
u.Writef("Delete By %s\n", id)
}
func TestMuxAPI(t *testing.T) {
@@ -544,7 +554,7 @@ func TestMuxAPI(t *testing.T) {
ctx.Next()
}, func(ctx *iris.Context) {
if ctx.Get("user") == "username" {
ctx.Write(middlewareResponseText)
ctx.WriteString(middlewareResponseText)
ctx.Next()
} else {
ctx.SetStatusCode(iris.StatusUnauthorized)
@@ -630,11 +640,11 @@ func TestMuxFireMethodNotAllowed(t *testing.T) {
iris.ResetDefault()
iris.Default.Config.FireMethodNotAllowed = true
h := func(ctx *iris.Context) {
ctx.Write("%s", ctx.MethodString())
ctx.WriteString(ctx.Method())
}
iris.Default.OnError(iris.StatusMethodNotAllowed, func(ctx *iris.Context) {
ctx.Write("Hello from my custom 405 page")
ctx.WriteString("Hello from my custom 405 page")
})
iris.Get("/mypath", h)
@@ -650,6 +660,7 @@ func TestMuxFireMethodNotAllowed(t *testing.T) {
iris.Close()
}
/*
var (
cacheDuration = 2 * time.Second
errCacheTestFailed = errors.New("Expected the main handler to be executed %d times instead of %d.")
@@ -680,7 +691,7 @@ func runCacheTest(e *httpexpect.Expect, path string, counterPtr *uint32, expecte
return nil
}
/*
Inside github.com/geekypanda/httpcache are enough, no need to add 10+ seconds of testing here.
func TestCache(t *testing.T) {
@@ -714,15 +725,18 @@ func TestCache(t *testing.T) {
*/
func TestRedirectHTTPS(t *testing.T) {
iris.ResetDefault()
host := "localhost:" + strconv.Itoa(getRandomNumber(4545, 5555))
expectedBody := "Redirected to https://" + host + "/redirected"
iris.Get("/redirect", func(ctx *iris.Context) { ctx.Redirect("/redirected") })
iris.Get("/redirected", func(ctx *iris.Context) { ctx.Text(iris.StatusOK, "Redirected to "+ctx.URI().String()) })
api := iris.New(iris.OptionIsDevelopment(true))
defer listenTLS(iris.Default, host)()
host := "localhost:" + strconv.Itoa(getRandomNumber(1717, 9281))
expectedBody := "Redirected to /redirected"
api.Get("/redirect", func(ctx *iris.Context) { ctx.Redirect("/redirected") })
api.Get("/redirected", func(ctx *iris.Context) { ctx.Text(iris.StatusOK, "Redirected to "+ctx.Path()) })
defer listenTLS(api, host)()
e := httptest.New(api, t)
e.GET("/redirect").Expect().Status(iris.StatusOK).Body().Equal(expectedBody)
e := httptest.New(iris.Default, t, httptest.ExplicitURL(true))
e.Request("GET", "https://"+host+"/redirect").Expect().Status(iris.StatusOK).Body().Equal(expectedBody)
}