-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee788c9
commit 529cd27
Showing
10 changed files
with
104 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const assert = require("assert") | ||
const request = require("supertest") | ||
|
||
const { app, requests } = require("../../authorization-server") | ||
const { deleteAllKeys } = require("../../utils") | ||
|
||
it("renders login page on successful request @authorization-server-render-login", () => { | ||
deleteAllKeys(requests) | ||
return request(app) | ||
.get("/authorize?client_id=my-client&scope=permission:name") | ||
.then((res) => { | ||
assert.equal( | ||
res.header["content-type"], | ||
"text/html; charset=utf-8", | ||
"The response doesn't seem to be an HTML page" | ||
) | ||
assert.equal( | ||
res.text.indexOf(`<title>Login Page</title>`) >= 0, | ||
true, | ||
"The returned page doesn't seem to be the login page" | ||
) | ||
assert.equal( | ||
res.text.indexOf( | ||
`Hi! You are logged in. Would you like to approve Sample Client` | ||
) >= 0, | ||
true, | ||
"Looks like the client parameter wasn't passed as a template variable" | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const assert = require("assert") | ||
const request = require("supertest") | ||
|
||
const { app, requests } = require("../../authorization-server") | ||
const { deleteAllKeys } = require("../../utils") | ||
|
||
it("stores the request in local memory @authorization-server-store-request", () => { | ||
deleteAllKeys(requests) | ||
return request(app) | ||
.get("/authorize?client_id=my-client&scope=permission:name") | ||
.then((res) => { | ||
const keys = Object.keys(requests) | ||
assert.equal( | ||
keys.length, | ||
1, | ||
"Only a single request object should be stored in the `requests` variable for each request made" | ||
) | ||
const storedRequest = requests[keys[0]] | ||
assert.equal( | ||
storedRequest.client_id, | ||
"my-client", | ||
"the stored request object should contain the client ID" | ||
) | ||
assert.equal( | ||
storedRequest.scope, | ||
"permission:name", | ||
"the stored request object should contain the client scope" | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const assert = require("assert") | ||
const request = require("supertest") | ||
|
||
const { app } = require("../../authorization-server") | ||
|
||
it("returns a 200 for a valid scope @authorization-server-validate-scope", () => { | ||
return request(app) | ||
.get("/authorize?client_id=my-client&scope=permission:name") | ||
.then((res) => { | ||
assert.notEqual(res.status, 404, "The `/authorize` route doesn't exist") | ||
assert.equal( | ||
res.status, | ||
200, | ||
"The `/authorize` route should return a 200 status if the client ID is valid" | ||
) | ||
|
||
return request(app).get( | ||
"/authorize?client_id=my-client&scope=permission:password" | ||
) | ||
}) | ||
.then((res) => { | ||
assert.equal( | ||
res.status, | ||
401, | ||
"The `/authorize` route should return a 401 status if the requested scope isn't allowed for the given client ID" | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters