-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added http.withCredentials option, closes #4
- Loading branch information
1 parent
2dd5d46
commit f3e4de0
Showing
9 changed files
with
1,231 additions
and
711 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
'use strict'; | ||
|
||
describe('parse from CORS with Access-Control-Allow-Origin: *', function() { | ||
var windowOnError, testDone; | ||
|
||
beforeEach(function() { | ||
windowOnError = global.onerror; | ||
global.onerror = function() { | ||
testDone(); | ||
return true; | ||
} | ||
}); | ||
|
||
afterEach(function() { | ||
global.onerror = windowOnError; | ||
}); | ||
|
||
it('should parse successfully with http.withCredentials = false', function() { | ||
var parser = new $RefParser(); | ||
return parser | ||
.parse('http://petstore.swagger.io:80/v2/swagger.json', { | ||
http: { withCredentials: false } | ||
}) | ||
.then(function(schema) { | ||
expect(schema).to.be.an('object'); | ||
expect(schema).not.to.be.empty; | ||
expect(parser.schema).to.equal(schema); | ||
}); | ||
}); | ||
|
||
if (userAgent.isBrowser) { | ||
it('should throw error in browser if http.withCredentials = true (default)', function(done) { | ||
testDone = done; | ||
var parser = new $RefParser(); | ||
return parser | ||
.parse('http://petstore.swagger.io:80/v2/swagger.json', { | ||
http: { withCredentials: true } | ||
}) | ||
.then(helper.shouldNotGetCalled) | ||
.catch(function(err) { | ||
expect(err.message).to.contain('Error downloading file'); | ||
done(); | ||
}); | ||
}); | ||
} | ||
}); |