-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a 'token' attribute for passing an authorization header wit…
…h the HTTP requests
- Loading branch information
Dirk Grappendorf
committed
Mar 17, 2015
1 parent
3ba72f1
commit 86dd824
Showing
8 changed files
with
68 additions
and
5 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
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,46 @@ | ||
<!doctype html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>grapp-rest-resource headers tests</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> | ||
|
||
<script src="../lib/web-component-tester/browser.js"></script> | ||
<script src="../lib/coffee-script/extras/coffee-script.js"></script> | ||
|
||
<link href="../grapp-rest-resource.html" rel="import"> | ||
</head> | ||
<body> | ||
|
||
<grapp-rest-resource id="element_with_headers" url="http://api.example.com" | ||
headers='{"foo":123}'></grapp-rest-resource> | ||
|
||
<grapp-rest-resource id="element_with_token" url="http://api.example.com" | ||
token="JWT"></grapp-rest-resource> | ||
|
||
<script type="text/coffeescript"> | ||
|
||
describe 'with defined hedaers attribute ', -> | ||
|
||
it 'sends the custom headers', -> | ||
element = document.querySelector '#element_with_headers' | ||
xhr_request = sinon.stub element.$.xhr, 'request' | ||
element.resource.index() | ||
expect(xhr_request).to.have.been.calledWith sinon.match {headers: {foo: 123}} | ||
|
||
describe 'with defined token attribute ', -> | ||
|
||
it 'sends the an authorization header', -> | ||
element = document.querySelector '#element_with_token' | ||
xhr_request = sinon.stub element.$.xhr, 'request' | ||
element.resource.index() | ||
expect(xhr_request).to.have.been.calledWith sinon.match {headers: {Authorization: 'JWT'}} | ||
|
||
</script> | ||
|
||
<script> | ||
</script> | ||
|
||
</body> | ||
</html> |
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 |
---|---|---|
|
@@ -12,7 +12,8 @@ | |
|
||
<script> | ||
WCT.loadSuites([ | ||
'basic.html' | ||
'basic.html', | ||
'headers.html' | ||
]); | ||
</script> | ||
|
||
|