Skip to content

Commit c1fa064

Browse files
MuhmdHsn313kataras
andauthored
Added support for third party packages on httptest package with tests & example. (kataras#1992)
* Added support for third party packages on httptest package with tests. * Update httptest.go Co-authored-by: Gerasimos (Makis) Maropoulos <[email protected]>
1 parent bdceab9 commit c1fa064

File tree

8 files changed

+483
-7
lines changed

8 files changed

+483
-7
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.idea
12
.vscode
23
.directory
34
coverage.out
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package main_test
2+
3+
import (
4+
"github.com/kataras/iris/v12"
5+
"testing"
6+
7+
. "github.com/onsi/ginkgo/v2"
8+
. "github.com/onsi/gomega"
9+
)
10+
11+
func TestGinkgotest(t *testing.T) {
12+
RegisterFailHandler(Fail)
13+
RunSpecs(t, "Ginkgotest Suite")
14+
}
15+
16+
func newApp(authentication iris.Handler) *iris.Application {
17+
app := iris.New()
18+
19+
app.Get("/", func(ctx iris.Context) { ctx.Redirect("/admin") })
20+
21+
// to party
22+
23+
needAuth := app.Party("/admin", authentication)
24+
{
25+
//http://localhost:8080/admin
26+
needAuth.Get("/", h)
27+
// http://localhost:8080/admin/profile
28+
needAuth.Get("/profile", h)
29+
30+
// http://localhost:8080/admin/settings
31+
needAuth.Get("/settings", h)
32+
}
33+
34+
return app
35+
}
36+
func h(ctx iris.Context) {
37+
username, password, _ := ctx.Request().BasicAuth()
38+
// third parameter it will be always true because the middleware
39+
// makes sure for that, otherwise this handler will not be executed.
40+
// OR:
41+
//
42+
// user := ctx.User().(*myUserType)
43+
// ctx.Writef("%s %s:%s", ctx.Path(), user.Username, user.Password)
44+
// OR if you don't have registered custom User structs:
45+
//
46+
// ctx.User().GetUsername()
47+
// ctx.User().GetPassword()
48+
ctx.Writef("%s %s:%s", ctx.Path(), username, password)
49+
}

Diff for: _examples/testing/ginkgotest/go.mod

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
module ginkgotest
2+
3+
go 1.19
4+
5+
replace github.com/kataras/iris/v12 => ../../../
6+
7+
require (
8+
github.com/kataras/iris/v12 v12.0.0-00010101000000-000000000000
9+
github.com/onsi/ginkgo/v2 v2.3.1
10+
github.com/onsi/gomega v1.22.1
11+
)
12+
13+
require (
14+
github.com/BurntSushi/toml v1.2.0 // indirect
15+
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
16+
github.com/CloudyKit/jet/v6 v6.1.0 // indirect
17+
github.com/Joker/jade v1.1.3 // indirect
18+
github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06 // indirect
19+
github.com/ajg/form v1.5.1 // indirect
20+
github.com/andybalholm/brotli v1.0.4 // indirect
21+
github.com/aymerick/douceur v0.2.0 // indirect
22+
github.com/davecgh/go-spew v1.1.1 // indirect
23+
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 // indirect
24+
github.com/fatih/structs v1.1.0 // indirect
25+
github.com/flosch/pongo2/v4 v4.0.2 // indirect
26+
github.com/golang/snappy v0.0.4 // indirect
27+
github.com/google/go-cmp v0.5.8 // indirect
28+
github.com/google/go-querystring v1.1.0 // indirect
29+
github.com/google/uuid v1.3.0 // indirect
30+
github.com/gorilla/css v1.0.0 // indirect
31+
github.com/gorilla/websocket v1.5.0 // indirect
32+
github.com/imkira/go-interpol v1.1.0 // indirect
33+
github.com/iris-contrib/httpexpect/v2 v2.3.1 // indirect
34+
github.com/iris-contrib/schema v0.0.6 // indirect
35+
github.com/josharian/intern v1.0.0 // indirect
36+
github.com/json-iterator/go v1.1.12 // indirect
37+
github.com/kataras/blocks v0.0.7 // indirect
38+
github.com/kataras/golog v0.1.7 // indirect
39+
github.com/kataras/pio v0.0.11 // indirect
40+
github.com/kataras/sitemap v0.0.6 // indirect
41+
github.com/kataras/tunnel v0.0.4 // indirect
42+
github.com/klauspost/compress v1.15.11 // indirect
43+
github.com/mailgun/raymond/v2 v2.0.47 // indirect
44+
github.com/mailru/easyjson v0.7.7 // indirect
45+
github.com/mattn/go-colorable v0.1.13 // indirect
46+
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
47+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
48+
github.com/modern-go/reflect2 v1.0.2 // indirect
49+
github.com/nxadm/tail v1.4.8 // indirect
50+
github.com/pmezard/go-difflib v1.0.0 // indirect
51+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
52+
github.com/schollz/closestmatch v2.1.0+incompatible // indirect
53+
github.com/sergi/go-diff v1.2.0 // indirect
54+
github.com/sirupsen/logrus v1.8.1 // indirect
55+
github.com/stretchr/testify v1.8.0 // indirect
56+
github.com/tdewolff/minify/v2 v2.12.4 // indirect
57+
github.com/tdewolff/parse/v2 v2.6.4 // indirect
58+
github.com/valyala/bytebufferpool v1.0.0 // indirect
59+
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
60+
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
61+
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
62+
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
63+
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
64+
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
65+
github.com/yosssi/ace v0.0.5 // indirect
66+
github.com/yudai/gojsondiff v1.0.0 // indirect
67+
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
68+
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0 // indirect
69+
golang.org/x/net v0.0.0-20221002022538-bcab6841153b // indirect
70+
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
71+
golang.org/x/text v0.4.0 // indirect
72+
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
73+
google.golang.org/protobuf v1.28.1 // indirect
74+
gopkg.in/ini.v1 v1.67.0 // indirect
75+
gopkg.in/yaml.v3 v3.0.1 // indirect
76+
moul.io/http2curl v1.0.0 // indirect
77+
)

0 commit comments

Comments
 (0)