AI_botter/node_modules/digest-fetch/test/digest-fetch-basic.js
2024-04-30 17:46:10 -08:00

30 lines
997 B
JavaScript

process.env.NO_DEPRECATION = 'digest-fetch';
var after = require('after')
var assert = require('assert')
var DigestFetch = require('../')
var factory = require('./test-server')
var chai = require('chai')
var expect = chai.expect
var chaiHttp = require('chai-http')
chai.use(chaiHttp)
chai.should()
var app = factory.getApp()
describe('digest-fetch', function(){
it('Test Basic Authentication', function() {
var client = new DigestFetch('test', 'test', { basic: true })
const auth = client.addBasicAuth().headers.Authorization
chai.request(app).get('/basic').set('Authorization', auth).then(res => {
expect(res).to.have.status(200)
})
})
it('Test Basic Authentication with wrong credential', function() {
var client = new DigestFetch('test', 'test-null', { basic: true })
const auth = client.addBasicAuth().headers.Authorization
chai.request(app).get('/basic').set('Authorization', auth).then(res => {
expect(res).to.have.status(401)
})
})
})