<commit_before>/**
 * UserController.test.js
 */
var request = require('supertest');
var should = require('should');

/**
 * Test invalid /user/password endpoint.
 */
describe('Requests to the root (/user/password) path with missing required body parameters.', function() {
  
  it('POST: Invalid password reset request with missing body parameters returns expected 422 - Unprocessable due to request validation error results.', function(done) {

    request(sails.hooks.http.app)
      .post('/api/v1/user/password')
      .send({

      })
      .expect(422)
      .expect("content-type", /json/)
      .end(function(err, res) {
        if (err) throw err;
        res.status.should.equal(422);
        res.body[0].should.have.property('error');
        done();
      });
  });
  
});

/**
 * Test /user/password endpoint.
 */
describe('Requests to the root (/user/password) path', function() {
  
  it('POST: Valid password request with only user_id returns expected results.', function(done) {

  request(sails.hooks.http.app)
    .post('/api/v1/user/password')
    .send({
      "user_id": "54f9e1c8469c64df6c8b4568"
    })
    .expect(200)
    .expect("content-type", /json/)
    .end(function(err, response) {
      if (err) {
        throw err;
      }
      response.status.should.equal(200);
      response.body[0].should.have.property('activity');
      response.body[0].activity.should.equal('user_password');
      response.body[0].should.have.property('email');
      response.body[0].should.have.property('uid');
      response.body[0].should.have.property('merge_vars');
      response.body[0].merge_vars.should.have.property('MEMBER_COUNT');
      response.body[0].merge_vars.should.have.property('FNAME');
      response.body[0].merge_vars.should.have.property('RESET_LINK');
      response.body[0].should.have.property('user_country');
      response.body[0].should.have.property('user_language');
      response.body[0].should.have.property('email_template');
      response.body[0].should.have.property('email_tags');
      response.body[0].email_tags[0].should.equal('drupal_user_password');
      response.body[0].should.have.property('activity_timestamp');
      response.body[0].should.have.property('application_id');
      done();
    });
  });
  
  it('POST: Valid password request with only email returns expected results.', function(done) {

  request(sails.hooks.http.app)
    .post('/api/v1/user/password')
    .send({
      "email": "<EMAIL>"
    })
    .expect(200)
    .expect("content-type", /json/)
    .end(function(err, response) {
      if (err) {
        throw err;
      }
      response.status.should.equal(200)
      response.body[0].should.have.property('activity');
      response.body[0].activity.should.equal('user_password');
      response.body[0].should.have.property('email');
      response.body[0].should.have.property('uid');
      response.body[0].should.have.property('merge_vars');
      response.body[0].merge_vars.should.have.property('MEMBER_COUNT');
      response.body[0].merge_vars.should.have.property('FNAME');
      response.body[0].merge_vars.should.have.property('RESET_LINK');
      response.body[0].should.have.property('user_country');
      response.body[0].should.have.property('user_language');
      response.body[0].should.have.property('email_template');
      response.body[0].should.have.property('email_tags');
      response.body[0].email_tags[0].should.equal('drupal_user_password');
      response.body[0].should.have.property('activity_timestamp');
      response.body[0].should.have.property('application_id');
      done();
    });
  });
  
  it('POST: Valid password request with only mobile returns expected results.', function(done) {

  request(sails.hooks.http.app)
    .post('/api/v1/user/password')
    .send({
      "mobile": "15556669999"
    })
    .expect(201)
    .expect("content-type", /json/)
    .end(function(err, response) {
      if (err) {
        throw err;
      }
      response.status.should.equal(200)
      response.body[0].should.have.property('activity');
      response.body[0].activity.should.equal('user_password');
      response.body[0].should.have.property('email');
      response.body[0].should.have.property('uid');
      response.body[0].should.have.property('merge_vars');
      response.body[0].merge_vars.should.have.property('MEMBER_COUNT');
      response.body[0].merge_vars.should.have.property('FNAME');
      response.body[0].merge_vars.should.have.property('RESET_LINK');
      response.body[0].should.have.property('user_country');
      response.body[0].should.have.property('user_language');
      response.body[0].should.have.property('email_template');
      response.body[0].should.have.property('email_tags');
      response.body[0].email_tags[0].should.equal('drupal_user_password');<commit_msg>Test for 200 rather than 201 response<commit_after>/**
 * UserController.test.js
 */
var request = require('supertest');
var should = require('should');

/**
 * Test invalid /user/password endpoint.
 */
describe('Requests to the root (/user/password) path with missing required body parameters.', function() {
  
  it('POST: Invalid password reset request with missing body parameters returns expected 422 - Unprocessable due to request validation error results.', function(done) {

    request(sails.hooks.http.app)
      .post('/api/v1/user/password')
      .send({

      })
      .expect(422)
      .expect("content-type", /json/)
      .end(function(err, res) {
        if (err) throw err;
        res.status.should.equal(422);
        res.body[0].should.have.property('error');
        done();
      });
  });
  
});

/**
 * Test /user/password endpoint.
 */
describe('Requests to the root (/user/password) path', function() {
  
  it('POST: Valid password request with only user_id returns expected results.', function(done) {

  request(sails.hooks.http.app)
    .post('/api/v1/user/password')
    .send({
      "user_id": "54f9e1c8469c64df6c8b4568"
    })
    .expect(200)
    .expect("content-type", /json/)
    .end(function(err, response) {
      if (err) {
        throw err;
      }
      response.status.should.equal(200);
      response.body[0].should.have.property('activity');
      response.body[0].activity.should.equal('user_password');
      response.body[0].should.have.property('email');
      response.body[0].should.have.property('uid');
      response.body[0].should.have.property('merge_vars');
      response.body[0].merge_vars.should.have.property('MEMBER_COUNT');
      response.body[0].merge_vars.should.have.property('FNAME');
      response.body[0].merge_vars.should.have.property('RESET_LINK');
      response.body[0].should.have.property('user_country');
      response.body[0].should.have.property('user_language');
      response.body[0].should.have.property('email_template');
      response.body[0].should.have.property('email_tags');
      response.body[0].email_tags[0].should.equal('drupal_user_password');
      response.body[0].should.have.property('activity_timestamp');
      response.body[0].should.have.property('application_id');

      done();
    });
  });
  
  it('POST: Valid password request with only email returns expected results.', function(done) {

  request(sails.hooks.http.app)
    .post('/api/v1/user/password')
    .send({
      "email": "<EMAIL>"
    })
    .expect(200)
    .expect("content-type", /json/)
    .end(function(err, response) {
      if (err) {
        throw err;
      }
      response.status.should.equal(200)
      response.body[0].should.have.property('activity');
      response.body[0].activity.should.equal('user_password');
      response.body[0].should.have.property('email');
      response.body[0].should.have.property('uid');
      response.body[0].should.have.property('merge_vars');
      response.body[0].merge_vars.should.have.property('MEMBER_COUNT');
      response.body[0].merge_vars.should.have.property('FNAME');
      response.body[0].merge_vars.should.have.property('RESET_LINK');
      response.body[0].should.have.property('user_country');
      response.body[0].should.have.property('user_language');
      response.body[0].should.have.property('email_template');
      response.body[0].should.have.property('email_tags');
      response.body[0].email_tags[0].should.equal('drupal_user_password');
      response.body[0].should.have.property('activity_timestamp');
      response.body[0].should.have.property('application_id');
      done();
    });
  });
  
  it('POST: Valid password request with only mobile returns expected results.', function(done) {

  request(sails.hooks.http.app)
    .post('/api/v1/user/password')
    .send({
      "mobile": "15556669999"
    })
    .expect(200)
    .expect("content-type", /json/)
    .end(function(err, response) {
      if (err) {
        throw err;
      }
      response.status.should.equal(200)
      response.body[0].should.have.property('activity');
      response.body[0].activity.should.equal('user_password');
      response.body[0].should.have.property('email');
      response.body[0].should.have.property('uid');
      response.body[0].should.have.property('merge_vars');
      response.body[0].merge_vars.should.have.property('MEMBER_COUNT');
      response.body[0].merge_vars.should.have.property('FNAME');
      response.body[0].merge_vars.should.have.property('RESET_LINK');
      response.body[0].should.have.property('user_country');
      response.body[0].should.have.property('user_language');
      response.body[0].should.have.property('email_template');
      response.body[0].should.have.property('email_tags');
      response.body[0].email_tags[0].should.equal('drupal_user_password');
{'fraction_non_alphanumeric': 0.17218269924734508, 'fraction_numerical': 0.022270337148159604, 'mean_word_length': 3.465930018416206, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, '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': '4437358', 'n_tokens_mistral': 3066, 'n_tokens_neox': 2988, 'n_words': 389}