<commit_before>var assert = require('assert');
var auth = require('..');

function request(authorization) {
  return {
    headers: {
      authorization: authorization
    }
  }
}

describe('auth(req)', function(){
  describe('with no Authorization field', function(){
    it('should return null', function(){
      var req = request();
      assert(null == auth(req));
    })
  })

  describe('with malformed Authorization field', function(){
    it('should return null', function(){
      var req = request('Something');
      assert(null == auth(req));
    })
  })

  describe('with malformed credentials', function(){
    it('should return null', function(){
      var req = request('basic Zm9vcgo=');
      assert(null == auth(req));
    })
  })

  describe('with valid credentials', function(){
    it('should return .user and .pass', function(){
      var req = request('basic Zm9vOmJhcg==');
      auth(req).should.eql({ name: 'foo', pass: '<PASSWORD>' });
    })
  })

  describe('with empty password', function(){
    it('should return .user and .pass', function(){
      var req = request('basic Zm9vOg==');
      auth(req).should.eql({ name: 'foo', pass: ''});
    })
  })

  describe('with empty userid', function(){
    it('should return .user and .pass', function(){
      var req = request('basic ' + new Buffer(':pass').toString('base64'));
      auth(req).should.eql({ name: '', pass: '<PASSWORD>'});
    })
  })

  describe('with empty userid and pass', function(){
    it('should return .user and .pass', function(){
      var req = request('basic ' + new Buffer(':').toString('base64'));
      auth(req).should.eql({ name: '', pass: ''});
    })
  })
})<commit_msg>tests: fix test names to align with code<commit_after>var assert = require('assert');
var auth = require('..');

function request(authorization) {
  return {
    headers: {
      authorization: authorization
    }
  }
}

describe('auth(req)', function(){
  describe('with no Authorization field', function(){
    it('should return null', function(){
      var req = request();
      assert(null == auth(req));
    })
  })

  describe('with malformed Authorization field', function(){
    it('should return null', function(){
      var req = request('Something');
      assert(null == auth(req));
    })
  })

  describe('with malformed credentials', function(){
    it('should return null', function(){
      var req = request('basic Zm9vcgo=');
      assert(null == auth(req));
    })
  })

  describe('with valid credentials', function(){
    it('should return .name and .pass', function(){
      var req = request('basic Zm9vOmJhcg==');
      auth(req).should.eql({ name: 'foo', pass: '<PASSWORD>' });
    })
  })

  describe('with empty password', function(){
    it('should return .name and .pass', function(){
      var req = request('basic Zm9vOg==');
      auth(req).should.eql({ name: 'foo', pass: ''});
    })
  })

  describe('with empty userid', function(){
    it('should return .name and .pass', function(){
      var req = request('basic ' + new Buffer(':pass').toString('base64'));
      auth(req).should.eql({ name: '', pass: '<PASSWORD>'});
    })
  })

  describe('with empty userid and pass', function(){
    it('should return .name and .pass', function(){
      var req = request('basic ' + new Buffer(':').toString('base64'));
      auth(req).should.eql({ name: '', pass: ''});
    })
  })
})
{'fraction_non_alphanumeric': 0.19317847691855336, 'fraction_numerical': 0.004116436342252279, 'mean_word_length': 3.350383631713555, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3894985', 'n_tokens_mistral': 1015, 'n_tokens_neox': 994, 'n_words': 271}