Permalink
Browse files

apache-crypt dependency is truly optional.

  • Loading branch information...
1 parent ed5e5e7 commit fc0265f051367d5f4c7a92de561216ae178b0a3e @gevorg gevorg committed Feb 10, 2014
Showing with 14 additions and 8 deletions.
  1. +1 −1 lib/auth/basic.coffee
  2. +2 −2 package.json
  3. +11 −5 tests/test-basic.coffee
View
2 lib/auth/basic.coffee
@@ -34,7 +34,7 @@ class Basic extends Base
]
else # File based.
for user in @options.users # Loop users to find the matching one.
- if user.username is username and htpasswd user.hash, password
+ if user.username is username and htpasswd.verify user.hash, password
found = true
break # Stop searching, we found him.
View
4 package.json
@@ -1,7 +1,7 @@
{
"name": "http-auth",
"description": "Node.js package for HTTP basic and digest access authentication.",
- "version": "2.1.5",
+ "version": "2.1.6",
"author": "Gevorg Harutyunyan (http://github.com/gevorg)",
"maintainers": [
{
@@ -27,7 +27,7 @@
"dependencies": {
"coffee-script": "1.6.3",
"node-uuid": "1.4.1",
- "htpasswd": "2.0.9"
+ "htpasswd": "2.1.0"
},
"devDependencies": {
"nodeunit": "0.8.1",
View
16 tests/test-basic.coffee
@@ -7,6 +7,9 @@ http = require 'http'
# Authentication library.
auth = require '../lib/http-auth'
+# htpasswd verification is reused.
+htpasswd = require 'htpasswd'
+
module.exports =
# Before each test.
@@ -39,12 +42,15 @@ module.exports =
# Correct Crypt details.
testSuccessCrypt: (test) ->
- callback = (error, response, body) -> # Callback.
- test.equals body, "Welcome to private area - vera!"
- test.done()
+ if htpasswd.isCryptInstalled()
+ callback = (error, response, body) -> # Callback.
+ test.equals body, "Welcome to private area - vera!"
+ test.done()
- # Test request.
- (request.get 'http://127.0.0.1:1337', callback).auth 'vera', 'kruta'
+ # Test request.
+ (request.get 'http://127.0.0.1:1337', callback).auth 'vera', 'kruta'
+ else
+ test.done()
# Correct MD5 details.
testSuccessMD5: (test) ->

0 comments on commit fc0265f

Please sign in to comment.