1
0
Fork 0
mirror of https://github.com/mmumshad/ansible-playable.git synced 2025-03-09 23:38:54 +00:00

Initial Commit

This commit is contained in:
Mumshad Mannambeth 2017-06-07 13:36:44 -04:00
commit c92f737237
273 changed files with 16964 additions and 0 deletions

View file

@ -0,0 +1,814 @@
/**
* Using Rails-like standard naming convention for endpoints.
* GET /api/ansible -> index
* POST /api/ansible -> create
* GET /api/ansible/:id -> show
* PUT /api/ansible/:id -> upsert
* PATCH /api/ansible/:id -> patch
* DELETE /api/ansible/:id -> destroy
*/
'use strict';
import jsonpatch from 'fast-json-patch';
import Ansible from './ansible.model';
var ssh2_exec = require('../../components/ssh/ssh2_exec');
var ansibleTool = require('../../components/ansible/ansible_tool');
function respondWithResult(res, statusCode) {
statusCode = statusCode || 200;
return function(entity) {
if(entity) {
return res.status(statusCode).json(entity);
}
return null;
};
}
function patchUpdates(patches) {
return function(entity) {
try {
// eslint-disable-next-line prefer-reflect
jsonpatch.apply(entity, patches, /*validate*/ true);
} catch(err) {
return Promise.reject(err);
}
return entity.save();
};
}
function removeEntity(res) {
return function(entity) {
if(entity) {
return entity.remove()
.then(() => {
res.status(204).end();
});
}
};
}
function handleEntityNotFound(res) {
return function(entity) {
if(!entity) {
res.status(404).end();
return null;
}
return entity;
};
}
function handleError(res, statusCode) {
statusCode = statusCode || 500;
return function(err) {
res.status(statusCode).send(err);
};
}
// Creates a new Ansible in the DB
export function command(req, res) {
var command = req.body.command;
var ansibleEngine = req.body.ansibleEngine;
ssh2_exec.executeCommand(command,
null,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
)
}
// Creates a new Ansible in the DB
export function modules(req, res) {
var ansibleEngine = req.body.ansibleEngine;
ansibleTool.getModules(function(data){
res.write(data)
},
function(data){
res.write(data);
res.end()
},
function(data){
res.write(data)
},
ansibleEngine
);
}
// Gets a single Deploy from the DB
export function getLogs(req, res) {
return Ansible.findById(req.params.id).exec()
.then(handleEntityNotFound(res))
.then(function(entity){
console.log("Getting logs " + entity.logfile);
ansibleTool.getLogs(entity.logfile,
function(successData){
return res.send(successData);
},
function(errorData){
return res.status(500).send(errorData)
}
);
return null;
})
.catch(handleError(res));
}
// Executes Ansible Play book in the backend
export function execute(req, res) {
//var inventory_file_contents = req.body.inventory_file_contents;
//var playbook_file_contents = req.body.playbook_file_contents;
var playbook_name = req.body.selectedPlaybook;
var inventory_file_name = req.body.inventory_file_name;
var tags = req.body.tags;
var limit_to_hosts = req.body.limit_to_hosts;
var verbose = req.body.verbose;
var check_mode = req.body.check_mode;
var ansibleEngine = req.body.ansibleEngine;
var project_folder = ansibleEngine.projectFolder;
console.log("Check_Mode=" + check_mode);
var time = new Date().getTime();
var logfilename = 'execution_' + time;
var tags_joined = tags;
if(typeof tags === 'object')tags_joined = tags.join(',');
var limit_to_hosts_joined = limit_to_hosts;
if(typeof limit_to_hosts === 'object')limit_to_hosts_joined = limit_to_hosts.join(',');
var ansibleObject = {
logfile: logfilename,
tags: tags_joined,
limit_to_hosts: limit_to_hosts,
verbose: verbose,
host: req.body.host,
check_mode: check_mode,
selectedPlaybook: req.body.selectedPlaybook,
selectedPlay: req.body.selectedPlay,
executionType: req.body.executionType,
executionName: req.body.executionName,
executionTime: time
};
var resultSent = false;
ansibleTool.executeAnsible(logfilename, project_folder, playbook_name, inventory_file_name, tags_joined, limit_to_hosts_joined, verbose,check_mode,
function(data){
//res.write(data)
if(!resultSent){
resultSent = true;
return Ansible.create(ansibleObject)
.then(respondWithResult(res, 201))
.catch(handleError(res));
}
},
function(data){
//res.write(data);
//res.end()
if(!resultSent){
resultSent = true;
return Ansible.create(ansibleObject)
.then(respondWithResult(res, 201))
.catch(handleError(res));
}
},
function(data){
//res.write(data)
if(!resultSent){
resultSent = true;
res.status(500).send(data)
}
},
ansibleEngine
);
}
/**
* List playbook tags
* ansible-playbook playbook.yml -i inventory --list-tags
* @param req
* @param res
*/
export function playbook_tags_list(req, res) {
var playbook_name = req.body.selectedPlaybook;
var inventory_file_name = req.body.inventory_file_name;
var ansibleEngine = req.body.ansibleEngine;
var project_folder = ansibleEngine.projectFolder;
ansibleTool.getTagList(project_folder, playbook_name, inventory_file_name,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function playbook_create(req, res) {
var playbook_file_contents = req.body.playbookFileContents;
var ansibleEngine = req.body.ansibleEngine;
var play_book_name = req.body.playbookName;
var project_folder = ansibleEngine.projectFolder;
play_book_name = play_book_name.replace(project_folder,'');
console.log("Playbook name = " + play_book_name);
var resultSent = false;
ansibleTool.writePlaybook(project_folder,play_book_name,playbook_file_contents,
function(data){
//res.write(data);
//res.end()
if(!resultSent){
resultSent = true;
res.send(data)
}
},
function(data){
//res.write(data)
if(!resultSent){
resultSent = true;
res.status(500).send(data)
}
},
ansibleEngine
);
}
export function playbook_delete(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var play_book_name = req.body.playbookName;
var project_folder = ansibleEngine.projectFolder;
var resultSent = false;
ansibleTool.deletePlaybook(project_folder,play_book_name,
function(data){
res.write(data)
},
function(data){
if(!resultSent){
resultSent = true;
res.write(data);
res.end();
}
},
function(data){
if(!resultSent){
resultSent = true;
res.status(500);
res.write(data);
res.end();
}
},
ansibleEngine
);
}
export function playbook_get(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var play_book_name = req.body.playbookName;
var project_folder = ansibleEngine.projectFolder;
var resultSent = false;
ansibleTool.readPlaybook(project_folder,play_book_name,
function(data){
res.write(data)
},
function(data){
if(!resultSent){
resultSent = true;
res.write(data);
res.end();
}
},
function(data){
if(!resultSent){
resultSent = true;
res.status(500);
res.write(data);
res.end();
}
},
ansibleEngine
);
}
export function playbook_list(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var project_folder = ansibleEngine.projectFolder;
ansibleTool.getPlaybookList(project_folder,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function roles_list(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var project_folder = ansibleEngine.projectFolder;
ansibleTool.getRolesList(project_folder,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function inventory_list(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var project_folder = ansibleEngine.projectFolder;
ansibleTool.getInventoryList(project_folder,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function inventory_get(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var project_folder = ansibleEngine.projectFolder;
var inventoryName = req.body.inventoryName;
ansibleTool.readInventoryFile(project_folder,inventoryName,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function inventory_create(req, res) {
var inventoryFileContents = req.body.inventoryFileContents;
var ansibleEngine = req.body.ansibleEngine;
var inventoryName = req.body.inventoryName;
var project_folder = ansibleEngine.projectFolder;
var file_path = project_folder + '/' + inventoryName;
ansibleTool.writeFile(file_path,inventoryFileContents,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine
);
}
export function inventory_delete(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var inventoryName = req.body.inventoryName;
var project_folder = ansibleEngine.projectFolder;
var file_path = project_folder + '/' + inventoryName;
ansibleTool.deleteFile(file_path,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine
);
}
export function update_groups_vars_file(req, res) {
var groupVarsContents = req.body.groupVarsContents;
var ansibleEngine = req.body.ansibleEngine;
var groupName = req.body.groupName;
var project_folder = ansibleEngine.projectFolder;
var file_path = project_folder + '/group_vars/' + groupName;
ansibleTool.writeFile(file_path, groupVarsContents,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine
);
}
export function get_groups_vars_file(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var groupName = req.body.groupName;
var project_folder = ansibleEngine.projectFolder;
var file_path = project_folder + '/group_vars/' + groupName;
ansibleTool.readFile(file_path,
null,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine
);
}
export function update_hosts_vars_file(req, res) {
var hostVarsContents = req.body.hostVarsContents;
var ansibleEngine = req.body.ansibleEngine;
var hostName = req.body.hostName;
var project_folder = ansibleEngine.projectFolder;
var file_path = project_folder + '/host_vars/' + hostName;
ansibleTool.writeFile(file_path, hostVarsContents,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine
);
}
export function get_hosts_vars_file(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var hostName = req.body.hostName;
var project_folder = ansibleEngine.projectFolder;
var file_path = project_folder + '/host_vars/' + hostName;
ansibleTool.readFile(file_path,
null,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine
);
}
/**
* Get variables for a host using Python AnsibleAPI
* @param req
* @param res
*/
export function get_hosts_vars(req,res){
var ansibleEngine = req.body.ansibleEngine;
var host_name = req.body.hostName;
var project_folder = ansibleEngine.projectFolder;
var inventory_file_name = req.body.inventoryFileName;
console.log('hostName=' + host_name)
ansibleTool.getVars(project_folder,inventory_file_name,host_name,
null,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine)
}
/**
* Get variables for a role using Python AnsibleAPI
* @param req
* @param res
*/
export function get_roles_vars(req,res){
var ansibleEngine = req.body.ansibleEngine;
var role_name = req.body.roleName;
var project_folder = ansibleEngine.projectFolder;
console.log('roleName=' + role_name);
ansibleTool.getRolesVars(project_folder,role_name,
null,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine)
}
export function roles_search_galaxy(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var searchText = req.body.searchText;
ansibleTool.searchRolesGalaxy(searchText,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function roles_search_github(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var searchText = req.body.searchText;
ansibleTool.searchRolesGithub(searchText,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
/**
* Create/Copy Role
* Create a new role if selectedRoleName is null
* Copy existing role if selectedRoleName is not null
* @param req
* @param res
*/
export function roles_create(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var roleName = req.body.roleName;
var selectedRoleName = req.body.selectedRoleName;
var createRoleFunction = ansibleTool.createRole;
if(selectedRoleName)
createRoleFunction = ansibleTool.copyRole;
createRoleFunction(roleName,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine,
selectedRoleName
);
}
export function roles_import(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var roleType = req.body.roleType;
var roleNameUri = req.body.roleNameUri;
ansibleTool.importRole(roleType,roleNameUri,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function roles_delete(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var roleName = req.body.roleName;
ansibleTool.deleteRole(roleName,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function roles_files(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var roleName = req.body.roleName;
ansibleTool.getRoleFiles(roleName,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function project_files(req, res) {
var ansibleEngine = req.body.ansibleEngine;
ansibleTool.getProjectFiles(
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function file_create(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var fileAbsolutePath = req.body.fileAbsolutePath;
ansibleTool.createFile(fileAbsolutePath,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function file_update(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var fileAbsolutePath = req.body.fileAbsolutePath;
var fileContents = req.body.fileContents;
ansibleTool.writeFile(fileAbsolutePath,fileContents,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
export function file_delete(req, res) {
var ansibleEngine = req.body.ansibleEngine;
var fileAbsolutePath = req.body.fileAbsolutePath;
ansibleTool.deleteFile(fileAbsolutePath,
function(data){
res.send(data)
},
function(data){
res.status(500).send(data);
},
ansibleEngine
);
}
// Gets a list of Ansibles
export function index(req, res) {
return Ansible.find().exec()
.then(respondWithResult(res))
.catch(handleError(res));
}
// Gets a single Ansible from the DB
export function show(req, res) {
return Ansible.findById(req.params.id).exec()
.then(handleEntityNotFound(res))
.then(respondWithResult(res))
.catch(handleError(res));
}
// Creates a new Ansible in the DB
export function create(req, res) {
return Ansible.create(req.body)
.then(respondWithResult(res, 201))
.catch(handleError(res));
}
// Upserts the given Ansible in the DB at the specified ID
export function upsert(req, res) {
if(req.body._id) {
Reflect.deleteProperty(req.body, '_id');
}
return Ansible.findOneAndUpdate({_id: req.params.id}, req.body, {new: true, upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec()
.then(respondWithResult(res))
.catch(handleError(res));
}
// Updates an existing Ansible in the DB
export function patch(req, res) {
if(req.body._id) {
Reflect.deleteProperty(req.body, '_id');
}
return Ansible.findById(req.params.id).exec()
.then(handleEntityNotFound(res))
.then(patchUpdates(req.body))
.then(respondWithResult(res))
.catch(handleError(res));
}
// Deletes a Ansible from the DB
export function destroy(req, res) {
return Ansible.findById(req.params.id).exec()
.then(handleEntityNotFound(res))
.then(removeEntity(res))
.catch(handleError(res));
}

View file

@ -0,0 +1,35 @@
/**
* Ansible model events
*/
'use strict';
import {EventEmitter} from 'events';
var AnsibleEvents = new EventEmitter();
// Set max event listeners (0 == unlimited)
AnsibleEvents.setMaxListeners(0);
// Model events
var events = {
save: 'save',
remove: 'remove'
};
// Register the event emitter to the model events
function registerEvents(Ansible) {
for(var e in events) {
let event = events[e];
Ansible.post(e, emitEvent(event));
}
}
function emitEvent(event) {
return function(doc) {
AnsibleEvents.emit(event + ':' + doc._id, doc);
AnsibleEvents.emit(event, doc);
};
}
export {registerEvents};
export default AnsibleEvents;

View file

@ -0,0 +1,190 @@
'use strict';
/* globals describe, expect, it, beforeEach, afterEach */
var app = require('../..');
import request from 'supertest';
var newAnsible;
describe('Ansible API:', function() {
describe('GET /api/ansible', function() {
var ansibles;
beforeEach(function(done) {
request(app)
.get('/api/ansible')
.expect(200)
.expect('Content-Type', /json/)
.end((err, res) => {
if(err) {
return done(err);
}
ansibles = res.body;
done();
});
});
it('should respond with JSON array', function() {
expect(ansibles).to.be.instanceOf(Array);
});
});
describe('POST /api/ansible', function() {
beforeEach(function(done) {
request(app)
.post('/api/ansible')
.send({
name: 'New Ansible',
info: 'This is the brand new ansible!!!'
})
.expect(201)
.expect('Content-Type', /json/)
.end((err, res) => {
if(err) {
return done(err);
}
newAnsible = res.body;
done();
});
});
it('should respond with the newly created ansible', function() {
expect(newAnsible.name).to.equal('New Ansible');
expect(newAnsible.info).to.equal('This is the brand new ansible!!!');
});
});
describe('GET /api/ansible/:id', function() {
var ansible;
beforeEach(function(done) {
request(app)
.get(`/api/ansible/${newAnsible._id}`)
.expect(200)
.expect('Content-Type', /json/)
.end((err, res) => {
if(err) {
return done(err);
}
ansible = res.body;
done();
});
});
afterEach(function() {
ansible = {};
});
it('should respond with the requested ansible', function() {
expect(ansible.name).to.equal('New Ansible');
expect(ansible.info).to.equal('This is the brand new ansible!!!');
});
});
describe('PUT /api/ansible/:id', function() {
var updatedAnsible;
beforeEach(function(done) {
request(app)
.put(`/api/ansible/${newAnsible._id}`)
.send({
name: 'Updated Ansible',
info: 'This is the updated ansible!!!'
})
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if(err) {
return done(err);
}
updatedAnsible = res.body;
done();
});
});
afterEach(function() {
updatedAnsible = {};
});
it('should respond with the updated ansible', function() {
expect(updatedAnsible.name).to.equal('Updated Ansible');
expect(updatedAnsible.info).to.equal('This is the updated ansible!!!');
});
it('should respond with the updated ansible on a subsequent GET', function(done) {
request(app)
.get(`/api/ansible/${newAnsible._id}`)
.expect(200)
.expect('Content-Type', /json/)
.end((err, res) => {
if(err) {
return done(err);
}
let ansible = res.body;
expect(ansible.name).to.equal('Updated Ansible');
expect(ansible.info).to.equal('This is the updated ansible!!!');
done();
});
});
});
describe('PATCH /api/ansible/:id', function() {
var patchedAnsible;
beforeEach(function(done) {
request(app)
.patch(`/api/ansible/${newAnsible._id}`)
.send([
{ op: 'replace', path: '/name', value: 'Patched Ansible' },
{ op: 'replace', path: '/info', value: 'This is the patched ansible!!!' }
])
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if(err) {
return done(err);
}
patchedAnsible = res.body;
done();
});
});
afterEach(function() {
patchedAnsible = {};
});
it('should respond with the patched ansible', function() {
expect(patchedAnsible.name).to.equal('Patched Ansible');
expect(patchedAnsible.info).to.equal('This is the patched ansible!!!');
});
});
describe('DELETE /api/ansible/:id', function() {
it('should respond with 204 on successful removal', function(done) {
request(app)
.delete(`/api/ansible/${newAnsible._id}`)
.expect(204)
.end(err => {
if(err) {
return done(err);
}
done();
});
});
it('should respond with 404 when ansible does not exist', function(done) {
request(app)
.delete(`/api/ansible/${newAnsible._id}`)
.expect(404)
.end(err => {
if(err) {
return done(err);
}
done();
});
});
});
});

View file

@ -0,0 +1,24 @@
'use strict';
import mongoose from 'mongoose';
import {registerEvents} from './ansible.events';
var AnsibleSchema = new mongoose.Schema({
name: String,
info: String,
active: Boolean,
logfile: String,
tags: String,
limit_to_hosts: String,
host: String,
verbose: String,
check_mode: Boolean,
selectedPlaybook: String,
selectedPlay: String,
executionType: String,
executionName: String,
executionTime: Date
});
registerEvents(AnsibleSchema);
export default mongoose.model('Ansible', AnsibleSchema);

View file

@ -0,0 +1,59 @@
'use strict';
var express = require('express');
var controller = require('./ansible.controller');
var router = express.Router();
router.get('/', controller.index);
router.post('/modules', controller.modules);
router.post('/command', controller.command);
router.post('/execute', controller.execute);
router.post('/project/files', controller.project_files);
router.post('/playbook/get', controller.playbook_get);
router.post('/playbook/create', controller.playbook_create);
router.post('/playbook/delete', controller.playbook_delete);
router.post('/playbook/list', controller.playbook_list);
router.post('/roles/create', controller.roles_create);
router.post('/roles/list', controller.roles_list);
router.post('/roles/search/galaxy', controller.roles_search_galaxy);
router.post('/roles/search/github', controller.roles_search_github);
router.post('/roles/delete', controller.roles_delete);
router.post('/roles/files', controller.roles_files);
router.post('/roles/import', controller.roles_import);
router.post('/tags/list', controller.playbook_tags_list);
router.post('/files/create', controller.file_create);
router.post('/files/update', controller.file_update);
router.post('/files/delete', controller.file_delete);
router.post('/inventory/list', controller.inventory_list);
router.post('/inventory/get', controller.inventory_get);
router.post('/inventory/create', controller.inventory_create);
router.post('/inventory/delete', controller.inventory_delete);
router.post('/vars_file/groups/update', controller.update_groups_vars_file);
router.post('/vars_file/groups/get', controller.get_groups_vars_file);
router.post('/vars_file/hosts/update', controller.update_hosts_vars_file);
router.post('/vars_file/hosts/get', controller.get_hosts_vars_file);
router.post('/vars/hosts/get', controller.get_hosts_vars);
router.post('/vars/roles/get', controller.get_roles_vars);
router.get('/logs/:id', controller.getLogs);
router.get('/:id', controller.show);
router.post('/', controller.create);
router.put('/:id', controller.upsert);
router.patch('/:id', controller.patch);
router.delete('/:id', controller.destroy);
module.exports = router;

View file

@ -0,0 +1,86 @@
'use strict';
/* globals sinon, describe, expect, it */
var proxyquire = require('proxyquire').noPreserveCache();
var ansibleCtrlStub = {
index: 'ansibleCtrl.index',
show: 'ansibleCtrl.show',
create: 'ansibleCtrl.create',
upsert: 'ansibleCtrl.upsert',
patch: 'ansibleCtrl.patch',
destroy: 'ansibleCtrl.destroy'
};
var routerStub = {
get: sinon.spy(),
put: sinon.spy(),
patch: sinon.spy(),
post: sinon.spy(),
delete: sinon.spy()
};
// require the index with our stubbed out modules
var ansibleIndex = proxyquire('./index.js', {
express: {
Router() {
return routerStub;
}
},
'./ansible.controller': ansibleCtrlStub
});
describe('Ansible API Router:', function() {
it('should return an express router instance', function() {
expect(ansibleIndex).to.equal(routerStub);
});
describe('GET /api/ansible', function() {
it('should route to ansible.controller.index', function() {
expect(routerStub.get
.withArgs('/', 'ansibleCtrl.index')
).to.have.been.calledOnce;
});
});
describe('GET /api/ansible/:id', function() {
it('should route to ansible.controller.show', function() {
expect(routerStub.get
.withArgs('/:id', 'ansibleCtrl.show')
).to.have.been.calledOnce;
});
});
describe('POST /api/ansible', function() {
it('should route to ansible.controller.create', function() {
expect(routerStub.post
.withArgs('/', 'ansibleCtrl.create')
).to.have.been.calledOnce;
});
});
describe('PUT /api/ansible/:id', function() {
it('should route to ansible.controller.upsert', function() {
expect(routerStub.put
.withArgs('/:id', 'ansibleCtrl.upsert')
).to.have.been.calledOnce;
});
});
describe('PATCH /api/ansible/:id', function() {
it('should route to ansible.controller.patch', function() {
expect(routerStub.patch
.withArgs('/:id', 'ansibleCtrl.patch')
).to.have.been.calledOnce;
});
});
describe('DELETE /api/ansible/:id', function() {
it('should route to ansible.controller.destroy', function() {
expect(routerStub.delete
.withArgs('/:id', 'ansibleCtrl.destroy')
).to.have.been.calledOnce;
});
});
});