<commit_before>// var assert = require('chai').assert;
// var config = require('../../lib/Config.js');
// var client = require('../../lib/Client.js');

// describe('connect.headersHash', function(){ 

// 	var oscConfigHeaders = {
// 		username: 'username',
// 		password: 'password',
// 		interface: 'interface',
// 		no_ssl_verify: true,
// 		suppress_rules: true
// 	}

// 	var rnClient = new client(oscConfigHeaders); 
// 	var oncHeaders = config.headersHash(rnClient,true);

// 	it('should take a client object and return a hash of header settings; ' +
// 		'the "suppress_rules" setting should return ' +
// 		'headers["OSvC-CREST-Suppress-All"] as true',function(){
// 		assert.strictEqual(oncHeaders["OSvC-CREST-Suppress-All"],true);
// 	});

// 	it('should take a boolean param for making PATCH requests; ' +
// 		'headers["X-HTTP-Method-Override"] as "PATCH"',function(){
// 		assert.strictEqual(oncHeaders["X-HTTP-Method-Override"],'PATCH');
// 	});

// 	var defaultConfigHeaders = {
// 		username: 'username',
// 		password: 'password',
// 		interface: 'interface'
// 	}

// 	var defaultClient = new client(defaultConfigHeaders); 
// 	var defaultHeaders = config.headersHash(defaultClient);

// 	it('should have headers set to undefined as a default',function(){
// 		assert.strictEqual(defaultHeaders["OSvC-CREST-Suppress-All"],undefined);
// 		assert.strictEqual(defaultHeaders["X-HTTP-Method-Override"],undefined);
// 	});

// });

// describe('config.clientUrl',function(){

// 	var oscConfigURL = {
// 		username: 'username123',
// 		password: '<PASSWORD>',
// 		interface: 'interface789',
// 		demo_site: true,
// 		version: 'v1.4',
// 		no_ssl_verify: true,
// 		suppress_rules: true
// 	}

// 	var rnClient = new client(oscConfigURL); 
	
// 	var oncURL = config.clientUrl(rnClient,"incidents");

// 	it('should always use "https" and "/services/rest/connect" in the url',function(){
// 		assert.match(oncURL,/\/services\/rest\/connect/);
// 		assert.match(oncURL,/https/);
// 	});

// 	it('should take a client object and change the url to include "rightnowdemo" if '+
// 		'the "demo_site" setting is set to true',function(){
// 		assert.match(oncURL,/rightnowdemo\.com/);

// 	});

// 	it('should take a username,password,and interface and change the url to include the username',function(){
// 		assert.match(oncURL,/username123/);
// 		assert.match(oncURL,/password456/);
// 		assert.match(oncURL,/interface789/);
// 	});


// 	it('should take a client object and change the url to include a different verions if '+
// 		'the "version" setting is changed',function(){
// 		assert.match(oncURL,/v1\.4/);
// 	});

// 	it('should take a resource URL and change the url',function(){
// 		assert.match(oncURL,/incidents/);
// 	});
	
// 	it('should equal "https://username123:password<EMAIL>@interface789.rightnowdemo.com/services/rest/connect/v1.4/incidents"',function(){
// 		assert.strictEqual(oncURL,"https://username123:password456@interface789.rightnowdemo.com/services/rest/connect/v1.4/incidents")
// 	});

	
// 	var defaultConfigURL = {
// 		username: 'username123',
// 		password: '<PASSWORD>',
// 		interface: 'interface789'
// 	}

// 	var defaultClient = new client(defaultConfigURL);

// 	var defaultResourceUrl = config.clientUrl(defaultClient);

// 	it('should take a not match incidents if the resource URL is not specified',function(){
// 		assert.notMatch(defaultResourceUrl,/incidents/);
// 	});

// 	it('"version" should be "v1.3/" if not specified',function(){
// 		assert.match(defaultResourceUrl,/v1\.3\//);
// 	});

// 	it('"custhelp" domain will be used if not specified',function(){
// 		assert.match(defaultResourceUrl,/custhelp.com/);
// 	});

// 	it('should equal "https://username123:password456@interface789.custhelp.com/services/rest/connect/v1.3/"',function(){
// 		assert.strictEqual(defaultResourceUrl,"https://username123:password456@interface789.custhelp.com/services/rest/connect/v1.3/")
// 	});

// });<commit_msg>updated tests for the config object as it has been updated for how it works<commit_after>var assert = require('chai').assert;
var config = require('../../lib/Config.js');
var client = require('../../lib/Client.js');

describe('connect.optionsFinalize', function(){ 

	var rnClient = new client({
		username: 'username',
		password: 'password',
		interface: 'interface',
		no_ssl_verify: true,
		suppress_rules: true
	});

	var options = {
		client: rnClient
	}

	var finalOptions = config.optionsFinalize("post",options,true);

	it('should take an HTTP verb and set the method property to match that verb',function(){
		assert.strictEqual(finalOptions.method,"post");
	});

	it('should take a client object and return a hash of options settings; ' +
		'the "suppress_rules" setting should return ' +
		'headers["OSvC-CREST-Suppress-All"] as true',function(){
		assert.strictEqual(finalOptions.headers["OSvC-CREST-Suppress-All"],true);
	});

	it('should take a boolean param for making PATCH requests; ' +
		'headers["X-HTTP-Method-Override"] as "PATCH"',function(){
		assert.strictEqual(finalOptions.headers["X-HTTP-Method-Override"],'PATCH');
	});

	var defaultConfigHeaders = new client({
		username: 'username',
		password: 'password',
		interface: 'interface'
	});

	var defaultOptions = {
		client: rnClient
	}

	var defaultHeaders = config.optionsFinalize("get", defaultOptions);

	it('should have headers set to undefined as a default',function(){
		assert.strictEqual(defaultHeaders["OSvC-CREST-Suppress-All"],undefined);
		assert.strictEqual(defaultHeaders["X-HTTP-Method-Override"],undefined);
	});

	var oscConfigURL = {
		client: new client({
			username: 'username123',
			password: '<PASSWORD>',
			interface: 'interface789',
			demo_site: true,
			version: 'v1.4',
			no_ssl_verify: true,
			suppress_rules: true
		}),
		url: "incidents"
	}

	var osvcURL = config.optionsFinalize("get", oscConfigURL);	

	it('should always use "https" and "/services/rest/connect" in the url',function(){
		assert.match(osvcURL.url,/\/services\/rest\/connect/);
		assert.match(osvcURL.url,/https/);
	});

	it('should take a client object and change the url to include "rightnowdemo" if '+
		'the "demo_site" setting is set to true',function(){
		assert.match(osvcURL.url,/rightnowdemo\.com/);
	});

	it('should take a username,password,and interface and change the url to include the interface',function(){
		assert.match(osvcURL.url,/interface789/);
	});

	it('should take a username,password and return an authorization header for basic auth',function(){
		let encryptedCred = "Basic " + Buffer.from("username123:password456").toString("base64");
		assert.strictEqual(osvcURL.headers["Authorization"], encryptedCred);
	});	


	it('should take a client object and change the url to include a different verions if '+
		'the "version" setting is changed',function(){
		assert.match(osvcURL.url,/v1\.4/);
	});

	it('should take a resource URL and change the url',function(){
		assert.match(osvcURL.url,/incidents/);
	});
	
	it('should equal "https://interface789.rightnowdemo.com/services/rest/connect/v1.4/incidents"',function(){
		assert.strictEqual(osvcURL.url,"https://interface789.rightnowdemo.com/services/rest/connect/v1.4/incidents")
	});

	
	var defaultConfigURL = {
		client: client({
			username: 'username123',
			password: '<PASSWORD>',
			interface: 'interface789'
		})
	}
	
	var defaultResourceUrl = config.optionsFinalize("get", defaultConfigURL);

	it('should take a not match incidents if the resource URL is not specified',function(){
		assert.notMatch(defaultResourceUrl.url,/incidents/);
	});

	it('"version" should be "v1.3/" if not specified',function(){
		assert.match(defaultResourceUrl.url,/v1\.3\//);
	});

	it('"custhelp" domain will be used if not specified',function(){
		assert.match(defaultResourceUrl.url,/custhelp.com/);
	});

	it('should equal "https://interface789.custhelp.com/services/rest/connect/v1.3/"',function(){
		assert.strictEqual(defaultResourceUrl.url,"https://interface789.custhelp.com/services/rest/connect/v1.3/")
	});

});
{'fraction_non_alphanumeric': 0.17189054726368158, 'fraction_numerical': 0.015049751243781094, 'mean_word_length': 4.194444444444445, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '5589198', 'n_tokens_mistral': 2814, 'n_tokens_neox': 2633, 'n_words': 545}