示例#1
0
	it("GET /uuid (invalid) - returns an 'unauthorized' error", function () {
		return tinyhttptest({http2: true, url: "https://localhost:" + port + "/uuid"})
			.cookies()
			.expectStatus(302)
			.expectHeader("location", login)
			.end();
	});
示例#2
0
	it("PATCH /nothere.html (404 / 'Not Found')", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/nothere.html", method: "patch"})
			.expectStatus(404)
			.expectHeader("allow", undefined)
			.expectValue("error", http.STATUS_CODES[404])
			.end();
	});
示例#3
0
	it("GET /nothere.x_%22%3E%3Cimg%20src=x%20onerror=prompt(1)%3E.html (404 / 'Not Found')", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/nothere.x_%22%3E%3Cimg%20src=x%20onerror=prompt(1)%3E.html"})
			.expectStatus(404)
			.expectHeader("allow", undefined)
			.expectValue("error", http.STATUS_CODES[404])
			.end();
	});
示例#4
0
	it("DELETE / (405 / 'Method Not Allowed')", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/", method: "delete"})
			.expectStatus(405)
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.expectValue("error", http.STATUS_CODES[405])
			.end();
	});
示例#5
0
	it("GET /././../README (404 / 'Not Found')", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/././../README"})
			.expectStatus(404)
			.expectHeader("allow", undefined)
			.expectValue("error", http.STATUS_CODES[404])
			.end();
	});
示例#6
0
	it("HEAD / (200 / empty)", function () {
		return tinyhttptest({url: "http://localhost:8001/", method: "head"})
			.expectStatus(200)
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.expectHeader("content-length", /53|58/) // macOS & Windows size on disk
			.expectBody(/^$/)
			.end();
	});
示例#7
0
	it("OPTIONS / (200 / empty)", function () {
		return tinyhttptest({url: "http://localhost:8001/", method: "options"})
			.expectStatus(200)
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.expectHeader("content-length", 0)
			.expectBody(/^$/)
			.end();
	});
示例#8
0
	it("HEAD / (200 / empty)", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/", method: "head"})
			.expectStatus(200)
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.expectHeader("content-length", 320)
			.expectBody(/^$/)
			.end();
	});
示例#9
0
	it("GET / (206 / 'Partial response - bytes=-5')", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/", headers: {range: "bytes=-5"}})
			.expectStatus(206)
			.expectHeader("content-range", /^bytes 285-290\/290$/)
			.expectHeader("content-length", undefined)
			.expectBody(/^:200}$/)
			.end();
	});
示例#10
0
	it("GET /uuid - returns a uuid (authorized)", function () {
		return tinyhttptest({http2: true, url: "https://*****:*****@localhost:" + port + "/uuid"})
			.expectJson()
			.expectStatus(200)
			.expectValue("links", [{uri: "/", rel: "collection"}])
			.expectValue("error", null)
			.expectValue("status", 200)
			.end();
	});
示例#11
0
	it("GET / (200 / 'Hello World!' - deflate)", function () {
		return tinyhttptest({url: "http://localhost:8001/", headers: {"accept-encoding": "deflate"}})
			.expectStatus(200)
			.expectHeader("content-encoding", "deflate")
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.expectHeader("transfer-encoding", "chunked")
			.expectHeader("content-length", undefined)
			.end();
	});
示例#12
0
	it("GET /invalid - returns a 'not found' error", function () {
		return tinyhttptest({http2: true, url: "https://localhost:" + port + "/invalid"})
			.expectJson()
			.expectStatus(404)
			.expectValue("data", null)
			.expectValue("error", "Not Found")
			.expectValue("status", 404)
			.end();
	});
示例#13
0
	it("GET / (206 / 'Partial response - offset')", function () {
		return tinyhttptest({url: "http://localhost:8001/", headers: {range: "2-4"}})
			.expectStatus(206)
			.expectHeader("transfer-encoding", "chunked")
			.expectHeader("content-range", /^bytes 2-4\/5(3|8)$/)
			.expectHeader("content-length", undefined)
			.expectBody(/^tml$/)
			.end();
	});
示例#14
0
	it("GET / (304 / empty & validation)", function () {
		return tinyhttptest({url: "http://localhost:8001/", headers: {"If-None-Match": etagValue}})
			.expectStatus(304)
			.expectHeader("Age", /\d+/)
			.expectHeader("Content-Length", void 0)
			.expectHeader("ETag", etagValue)
			.expectBody(/^$/)
			.end();
	});
示例#15
0
	it("PATCH / - returns a 'method not allowed' error", function () {
		return tinyhttptest({http2: true, url: "https://localhost:" + port, method: "patch"})
			.expectJson()
			.expectStatus(405)
			.expectValue("data", null)
			.expectValue("error", "Method Not Allowed")
			.expectValue("status", 405)
			.end();
	});
示例#16
0
	it("GET /null (200 / 'null')", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/null"})
			.expectStatus(200)
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.expectValue("data", null)
			.expectValue("error", null)
			.expectValue("status", 200)
			.end();
	});
示例#17
0
	it("GET / (304 / empty - ETag reuse)", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/"})
			.etags()
			.expectStatus(304)
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.expectHeader("content-length", undefined)
			.expectBody(/^$/)
			.end();
	});
示例#18
0
	it("HEAD /no-cache (200 / 'Success' / No Etag)", function () {
		return tinyhttptest({url: "http://localhost:8001/no-cache", method: "head"})
			.expectStatus(200)
			.expectHeader("Allow", "GET, HEAD, OPTIONS")
			.expectHeader("Cache-Control", "no-cache")
			.expectHeader("Content-Type", "text/plain")
			.expectHeader("ETag", void 0)
			.expectBody(/^$/)
			.end();
	});
示例#19
0
	it("POST /auth/login (invalid / no CSRF token) - returns an 'unauthorized' error", function () {
		return tinyhttptest({http2: true, url: "https://localhost:" + port + login, method: "post"})
			.cookies()
			.json({username: "******", password: invalid})
			.expectStatus(403)
			.expectValue("data", null)
			.expectValue("error", "CSRF token missing")
			.expectValue("status", 403)
			.end();
	});
示例#20
0
	it("POST /auth/login - redirects to a predetermined URI", function () {
		return tinyhttptest({http2: true, url: "https://localhost:" + port + login, method: "post"})
			.cookies()
			.reuseHeader(csrf)
			.json({username: "******", password: valid})
			.expectStatus(302)
			.expectHeader("content-type", undefined)
			.expectHeader("location", "/")
			.end();
	});
示例#21
0
	it("GET / (200 / 'Hello World!')", function () {
		return tinyhttptest({url: "http://localhost:8001/"})
			.etags()
			.expectStatus(200)
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.expectHeader("transfer-encoding", "chunked")
			.expectHeader("content-length", undefined)
			.expectBody(/Hello world!/)
			.end();
	});
示例#22
0
	it("GET / (200 / 'Success' / No Etag)", function () {
		return tinyhttptest({url: "http://localhost:8001/"})
			.expectStatus(200)
			.expectHeader("Allow", "GET, HEAD, OPTIONS")
			.expectHeader("Cache-Control", "public")
			.expectHeader("Content-Type", "text/plain")
			.expectHeader("ETag", etagValue)
			.expectBody(/^Hello World!$/)
			.end();
	});
示例#23
0
	it("GET /uuid (session) - returns a version 4 uuid", function () {
		return tinyhttptest({http2: true, url: "https://localhost:" + port + "/uuid"})
			.cookies()
			.expectStatus(200)
			.expectJson()
			.expectValue("links", [{uri: "/", rel: "collection"}])
			.expectValue("error", null)
			.expectValue("status", 200)
			.end();
	});
示例#24
0
	it("OPTIONS / (200 / empty)", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/", method: "options"})
			.expectStatus(200)
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.expectHeader("content-length", 320)
			.expectValue("data", /\w/)
			.expectValue("error", null)
			.expectValue("status", 200)
			.end();
	});
示例#25
0
	it("GET /auth/login - returns an authentication message", function () {
		return tinyhttptest({http2: true, url: "https://localhost:" + port + login})
			.cookies()
			.captureHeader(csrf)
			.expectJson()
			.expectStatus(200)
			.expectValue("links", [{
				"uri": "/auth",
				"rel": "collection"
			}])
			.expectValue("data", {instruction: "POST 'username' & 'password' to authenticate"})
			.expectValue("error", null)
			.expectValue("status", 200)
			.end();
	});
示例#26
0
	it("GET / - returns links", function () {
		return tinyhttptest({http2: true, url: "https://localhost:" + port})
			.expectJson()
			.expectStatus(200)
			.expectValue("links", [{uri: "/empty", rel: "item"},
				{uri: "/items", rel: "item"},
				{uri: "/somethings", rel: "item"},
				{uri: "/test", rel: "item"},
				{uri: "/things", rel: "item"},
				{uri: "/?page=2&page_size=5", rel: "last"}])
			.expectValue("data", ["empty", "items", "somethings", "test", "things"])
			.expectValue("error", null)
			.expectValue("status", 200)
			.end();
	});
示例#27
0
	it("GET / - returns an array of endpoints (authorized)", function () {
		return tinyhttptest({http2: true, url: "https://localhost:" + port, headers: {authorization: "Bearer abc-123"}})
			.expectJson()
			.expectStatus(200)
			.expectValue("links", [{uri: "/empty", rel: "item"},
				{uri: "/items", rel: "item"},
				{uri: "/somethings", rel: "item"},
				{uri: "/test", rel: "item"},
				{uri: "/things", rel: "item"},
				{uri: "/?page=2&page_size=5", rel: "last"}])
			.expectValue("data", ["empty", "items", "somethings", "test", "things"])
			.expectValue("error", null)
			.expectValue("status", 200)
			.end();
	});
示例#28
0
	it("GET /sample/ (200 / HTML)", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/sample/"})
			.expectStatus(200)
			.expectHeader("allow", "GET, HEAD, OPTIONS")
			.end();
	});
示例#29
0
	it("GET /sample (200 / redirect)", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/sample"})
			.expectStatus(301)
			.expectHeader("location", "/sample/")
			.end();
	});
示例#30
0
	it("GET / (200 / 'Array' - ETag capture)", function () {
		return tinyhttptest({url: "http://localhost:" + port + "/"})
			.etags()
			.expectStatus(200)
			.end();
	});