<commit_before>'use strict';
const chai = require('chai')
const expect = chai.expect
const mojang = require('../')

describe('mojang.auth()', () => {

  // TODO implement test scenario with valid credentials 
<commit_msg>Added http interceptor for auth tests<commit_after>'use strict';
const chai = require('chai')
const expect = chai.expect
const nock = require('nock')
const mojang = require('../')

describe('mojang.auth()', () => {

  before((done) => {

    nock('https://authserver.mojang.com')
      .post('/authenticate', {
        username: '<EMAIL>'
      })
      .reply(200, {
        accessToken: '<KEY>',
        clientToken: '<PASSWORD>'
      })
      .post('/authenticate')
      .reply(200, {
        error: 'ForbiddenOperationException',
        errorMessage: 'Invalid credentials. Invalid username or password.'
      })
      done()
  })

  it('should return an access token with valid credentials', (done) => {
    mojang.auth('<EMAIL>', 'password')
      .then((tokens) => {
        expect(tokens).to.have.property('accessToken')
        expect(tokens).to.have.property('clientToken')
        done()
      })
      .catch((err) => {
        expect(err).to.be.null
        done()
      })
  })

{'fraction_non_alphanumeric': 0.17269736842105263, 'fraction_numerical': 0.004934210526315789, 'mean_word_length': 2.7446153846153845, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '5579324', 'n_tokens_mistral': 378, 'n_tokens_neox': 368, 'n_words': 79}