var RippleGateway = require('../../lib/http_client.js').Gateway;
var crypto = require('crypto');
var assert = require('assert');

function rand() {
  return crypto.randomBytes(32).toString('hex');
}

describe('Users', function() {
  before(function(){
    client = new RippleGateway.Client({
      api: 'https://localhost:4000'
    });
  })

  it('should create a new user given a name and password', function(done){
    // POST /users
    client.user = rand();
    client.secret = rand();
    client.createUser({}, function(err, user) {
      if (err) {
        console.log('error', err);
      } else {
        assert(user.id > 0);
      }
      done();
    })
  });

  it("should verify a user's credentials given a name and password", function(done){
    // GET /users
    client.secret = rand();
    client.createUser({}, function(err, user) {
      var id = user.id;
      client.getUser({}, function(err, user) {
        assert(id == user.id);
        done();
      });
    });
  });

  it('should not allow the creation of two users with the same name', function(done){
    // POST /users
    client.user = rand();
    client.secret = rand();
    client.createUser({}, function(err, user){
      var id = user.id;
      client.secret = rand();
      client.createUser({}, function(err, user){
        assert(typeof err != 'undefined');
        assert(user == 'Unauthorized');
        done();
      });
    });
  });

  it('should not allow the creation of a user with the name "admin"', function(done){
    // POST /users
    client.user = 'admin';
    client.secret = rand();
    client.createUser({}, function(err, user){
      assert(user == 'invalid admin key');
      done();
    });
  });

});

@@ -758,32 +758,58 @@
   // GET /users%0A
+    client.user = rand();%0A
     client.secre
@@ -1206,32 +1206,33 @@
 nction(err, user
+1
 )%7B%0A      var id 
@@ -1229,32 +1229,33 @@
    var id = user
+1
 .id;%0A      clien
@@ -1311,32 +1311,33 @@
 nction(err, user
+2
 )%7B%0A        asser
@@ -1385,27 +1385,32 @@
 ert(
+typeof 
 user
+2
  == '
-Unauthoriz
+undefin
 ed')
@@ -1669,42 +1669,67 @@
     
-assert(user == 'invalid admin key'
+console.log(err);%0A      console.log(user);%0A      assert(err
 );%0A 

Fix user test.