Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Basic tests added.

  • Loading branch information...
commit e70f54d9fe1b24d97633ae58f01d8962687601f5 1 parent 33d69a3
@gevorg authored
Showing with 97 additions and 4 deletions.
  1. +2 −2 README.md
  2. +2 −2 package.json
  3. +93 −0 tests/test-htpasswd.js
View
4 README.md
@@ -1,5 +1,5 @@
# htpasswd
-[Node.js](http://nodejs.org/) package for htpasswd utility.
+[Node.js](http://nodejs.org/) package for HTTP Basic Authentication password file utility.
## Installation
@@ -36,7 +36,7 @@ $ htpasswd -nb[p] username password
It uses [nodeunit](https://github.com/caolan/nodeunit/), so just run following command in package directory:
```bash
-$ nodeunit tests/*
+$ nodeunit tests
```
## Issues
View
4 package.json
@@ -1,7 +1,7 @@
{
"name": "htpasswd",
- "description": "Node.js package for htpasswd utility.",
- "version": "1.0.1",
+ "description": "Node.js package for HTTP Basic Authentication password file utility.",
+ "version": "1.0.2",
"author": "Gevorg Harutyunyan (http://github.com/gevorg)",
"maintainers": [
{
View
93 tests/test-htpasswd.js
@@ -0,0 +1,93 @@
+/**
+ * htpasswd module.
+ */
+var htpasswd = require('../lib/htpasswd');
+
+/**
+ * Test for parseInput, plain success case.
+ */
+exports['testParseInputSuccessPlain'] = function (test) {
+ // Test input.
+ var args = ['node', 'htpasswd.js', '-npb', 'mia', 'supergirl'];
+
+ // Should not throw an error.
+ test.doesNotThrow( function() {
+ // Source method call.
+ htpasswd.parseInput(args);
+ }, "Should not throw an error!");
+
+ // Assertions.
+ test.equal(htpasswd.username, args[3], "Username is wrong!");
+ test.equal(htpasswd.password, args[4], "Password is wrong!");
+
+ // Test is done.
+ test.done();
+};
+/**
+ * Test for parseInput, encrypted success case.
+ */
+exports['testParseInputSuccessEncrypted'] = function (test) {
+ // Test input.
+ var args = ['node', 'htpasswd.js', '-nb', 'mia', 'supergirl'];
+
+ // Should not throw an error.
+ test.doesNotThrow( function() {
+ // Source method call.
+ htpasswd.parseInput(args);
+ }, "Should not throw an error!");
+
+ // Assertions.
+ test.equal(htpasswd.username, args[3], "Username is wrong!");
+ test.notEqual(htpasswd.password, '', "Password is empty!");
+
+ // Test is done.
+ test.done();
+};
+/**
+ * Test for parseInput, fail case.
+ */
+exports['testParseInputFailNoArg'] = function (test) {
+ // Test input.
+ var args = ['node', 'htpasswd.js'];
+
+ // Should throw an error.
+ test.throws( function() {
+ // Source method call.
+ htpasswd.parseInput(args);
+ }, "Should throw an error!");
+
+ // Test is done.
+ test.done();
+};
+/**
+ * Test for parseInput, fail case.
+ */
+exports['testParseInputFailArgCount'] = function (test) {
+ // Test input.
+ var args = ['node', 'htpasswd.js', '-nb'];
+
+ // Should throw an error.
+ test.throws( function() {
+ // Source method call.
+ htpasswd.parseInput(args);
+ }, "Should throw an error!");
+
+ // Test is done.
+ test.done();
+};
+/**
+ * Test for parseInput, fail case.
+ */
+exports['testParseInputFailPassword'] = function (test) {
+ // Test input.
+ var args = ['node', 'htpasswd.js', '-nb', 'mia'];
+
+ // Should not throw an error.
+ test.throws( function() {
+ // Source method call.
+ htpasswd.parseInput(args);
+ }, "Should throw an error!");
+
+ // Test is done.
+ test.done();
+};
Please sign in to comment.
Something went wrong with that request. Please try again.