• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TykTechnologies / tyk / 6682

Build:
DEFAULT BRANCH: master
Ran 22 May 2019 04:37PM UTC
Jobs 1
Files 111
Run time 7s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
6682

push

travis-ci

buger
Create testutil.go (#2284)

This PR creates `testutil.go`. The purpose is to be able to import test functions in other projects.

For example, in dashboard, this PR provides us to write the following test:

```go
func TestAPIContext_RevokeDeveloperKey(t *testing.T) {
	g := gateway.StartTest()
	defer g.Close()

	Tyk.(*TykApi).Port = strconv.Itoa(g.GlobalConfig.ListenPort)
	sessionID, _ := UserSessions.CreateAPISession(&testUser)

	ts := newTykTestServer(tykTestServerConfig{accessKey: sessionID})
	defer ts.Close()

	api := gateway.BuildAndLoadAPI(func(spec *gateway.APISpec) {
		spec.Proxy.ListenPath = "/"
		spec.UseKeylessAccess = false
	})[0]

	key := gateway.CreateSession(func(s *user.SessionState) {
		s.AccessRights = map[string]user.AccessDefinition{api.APIID: {
			APIID: api.APIID,
		}}
	})

	developer := createSampleDeveloper(func(developer *PortalDeveloper) {
		developer.OrgId = testOrg.Id.Hex()
		developer.ApiKeys = map[string]string{
			api.APIID: key,
		}
	})

	authHeaders := map[string]string{
		"authorization": key,
	}

	g.Run(t, test.TestCase{Path: "/", Headers: authHeaders, Code: http.StatusOK})

	headers := map[string]string{"authorization": testUser.AccessKey}
	revokePath := fmt.Sprintf("/api/portal/developers/key/%s/%s/%s", api.APIID, key, developer.Id.Hex())

	_, _ = ts.Run(t, []test.TestCase{
		{Method: http.MethodDelete, Headers: headers, Path: revokePath, Code: http.StatusOK, BodyMatch: "User key revoked"},
	}...)

	g.Run(t, test.TestCase{Path: "/", Headers: authHeaders, Code: http.StatusForbidden})
}
```

11310 of 17745 relevant lines covered (63.74%)

0.71 hits per line

Jobs
ID Job ID Ran Files Coverage
2 6682.2 (LATEST_GO=true) 22 May 2019 04:37PM UTC 0
63.74
Travis Job 6682.2
Source Files on build 6682
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #6682
  • 557e68af on github
  • Prev Build on master (#6675)
  • Next Build on master (#6695)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc