Пример #1
0
describe('Authenticated routes', function () {
    frisby.globalSetup({
      request: {
        headers: { 'x-access-token': 'fa8426a0-8eaf-4d22-8e13-7c1b16a9370c' }
      }
    });

    describe('Product routes', function () {
        frisby.create('POST product Authenticated should return 200')
            .post(URL + '/api/products/addproduct', {
                sku: '1234'
            }, {json: true})
            .expectStatus(200)
            .expectHeaderContains('content-type', 'application/json')
        .toss();
    });

    describe('Order Routes', function () {
        frisby.create('GET all orders Authenticated should return 200')
            .get(URL + '/api/orders')
            .expectStatus(200)
        .toss();
    });

    describe('User routes', function () {
        frisby.create('Get all users should return 200')
            .get(URL + '/api/user')
            .expectStatus(200)
        .toss();
    });

});
Пример #2
0
function init(_baseURL) {
  baseURL = _baseURL;
  frisby.globalSetup({ // globalSetup is for ALL requests
    request: {
      headers: { 'Content-type': 'application/json' }
    }
  });
}
Пример #3
0
    .after(function (err, res, body) {
        var sid = res.headers['set-cookie'][0];
        var sidSig = res.headers['set-cookie'][1];

        frisby.globalSetup({
            request: {
                headers: {
                    cookie: sid.split(';')[0] + ';' + sidSig.split(';')[0]
                }
            }
        });

    })
Пример #4
0
	.after(function (err, res, body) {
		var rvdCookie = res.headers['set-cookie'][0].split(';')[0];
		frisby.globalSetup({
		  request: {
			headers: { 
				'Content-Type': 'application/json;charset=utf-8',  
				'Cookie': rvdCookie
			}
		  }
		});		
		//console.log("Using rvdCookie: " + rvdCookie);
		
		// Create a project for testing upon
		frisby.create('Create WebTrigger test project')
			.put( config.baseURL + 'restcomm-rvd/services/projects/' + config.projectName + '/?kind=voice')
			.expectStatus(200)
			.after(function () {
				frisby.create('Retrieve WebTrigger info  for project with no WebTrigger yet')
					.get( config.baseURL + 'restcomm-rvd/services/projects/' + config.projectName + '/cc')
					.expectStatus(404)
					.after( function () {
						
						frisby.create('Save WebTrigger info')
							.post( config.baseURL + 'restcomm-rvd/services/projects/' + config.projectName + '/cc',
								{"lanes":[{"startPoint":{"to":config.toAddress,"from":""}}]},
								{"json":true})
							.expectStatus(200)
							.after( function () {
								
								frisby.create('Retrieve WebTrigger info')
									.get( config.baseURL + 'restcomm-rvd/services/projects/' + config.projectName + '/cc')
									.expectStatus(200)
									.expectJSON( "lanes", [ {startPoint: { to: config.toAddress}} ] )
									.after(function () {
										frisby.create('Remove WebTrigger test project')
											.delete( config.baseURL + 'restcomm-rvd/services/projects/' + config.projectName )
											.expectStatus(200)
										.toss();	
									})
								.toss();
								
							})
						.toss();			
					})
				.toss();
			})
		.toss();		
		
	})
 .afterJSON(function (json) {
     frisby.globalSetup({
         request: {
             headers: { 'Authorization': 'Bearer ' + json.access_token }
         }
     });
     var course = {
         courseDescription: 'Gopher Hills - White Tees'
     };
     frisby.create('Create course')
         .post(host + '/api/users/courses', course, { json: true })
         .expectHeaderContains('content-type', 'json')
         .expectStatus(201)
         .afterJSON(function (myCourse) {
             var key = myCourse.key;
             myCourse.courseDescription = 'Gopher Hills - White Tees - Front 9';
             frisby.create('Get courses')
                 .get(host + '/api/users/courses')
                 .expectStatus(200)
                 .expectHeaderContains('content-type', 'application/json')
                 .expectJSONTypes('*', { //weird array checking syntax: http://frisbyjs.com/docs/api/
                     key: Number,
                     userId: String,
                     courseDescription: String
                 })
                 .toss();
             frisby.create('Get course by id')
                 .get(host + '/api/users/courses/' + key)
                 .expectStatus(200)
                 .expectHeaderContains('content-type', 'application/json')
                 .expectJSONTypes({
                     key: Number,
                     userId: String,
                     courseDescription: String
                 })
                 .toss();
             frisby.create('Update a course')
                 .put(host + '/api/users/courses/' + key, myCourse, {json: true})
                 .expectStatus(204)
                 .after(function () {
                     frisby.create('Delete a course')
                         .delete(host + '/api/users/courses/' + key)
                         .expectStatus(200)
                         .toss();
                 })
                 .toss();
         })
         .toss();
 })
 .afterJSON(function (json) {
     frisby.globalSetup({
         request: {
             headers: {'Authorization': 'Bearer ' + json.access_token}
         }
     });
     frisby.create('Create a course to play on')
         .post(host + '/api/users/courses', {courseDescription: 'test course'}, {json: true})
         .expectStatus(201)
         .afterJSON(function (course) {
             var round = {
                 roundDate: '2104-12-20',
                 courseKey: course.key,
                 holesCount: 9
             };
             frisby.create('Create round')
                 .post(host + '/api/rounds', round, {json: true})
                 .expectHeaderContains('content-type', 'json')
                 .expectStatus(201)
                 .afterJSON(function (newRound) {
                     newRound.teeShots.push({
                         roundKey: newRound.key,
                         holeNumber: 1,
                         clubKey: 1,
                         distanceNumber: 255,
                         resultId: 0,
                         resultXNumber: 25,
                         resultYNumber: 39
                     });
                     newRound.scoreNumber = 36;
                     newRound.fairwaysNumber = 4;
                     frisby.create('Update round')
                         .put(host + '/api/rounds/' + newRound.key, newRound, {json: true})
                         .expectStatus(204)
                         .after(function () {
                             frisby.create('Delete round')
                                 .delete(host + '/api/rounds/' + newRound.key)
                                 .expectStatus(200)
                                 .toss();
                         })
                         .toss();
                 })
                 .toss();
         })
         .toss();
 })
	.after(function (err, res, body) {
		var rvdCookie = res.headers['set-cookie'][0].split(';')[0];
		frisby.globalSetup({
		  request: {
			headers: { 
				'Content-Type': 'application/json;charset=utf-8',  
				'Cookie': rvdCookie
			}
		  }
		});		
		//console.log("Using rvdCookie: " + rvdCookie);
		
		
		// Basic project management
		frisby.create('Create a voice project')
			.put( config.baseURL + 'restcomm-rvd/services/projects/' + config.projectName + '/?kind=voice')
			.expectStatus(200)
			.after(function (err,res,body) {
				
				frisby.create('Retrieve voice project')
					.get( config.baseURL + 'restcomm-rvd/services/projects/' + config.projectName )
					.expectStatus(200)
					.expectJSON( "header", { projectKind: 'voice', startNodeName: 'start', version: config.rvdProjectVersion, owner: config.username })
					.after(function () {
						frisby.create('Rename project')
							.put( config.baseURL + 'restcomm-rvd/services/projects/' + config.projectName + '/rename?newName=' + config.projectRenamed )
							.expectStatus(200)
							.after(function () {
								frisby.create('Remove project')
									.delete( config.baseURL + 'restcomm-rvd/services/projects/' + config.projectRenamed )
									.expectStatus(200)
								.toss();								
							})
						.toss();
					})
				.toss();
			})
		.toss();		
		
	})
	.afterJSON(function(data){
		
		frisby.globalSetup({
			request: {
				headers: {
					token: data.TokenString
				},
			json: true
			//inspectOnFailure: true

			}
		})
	
		frisby.create('Get all projects and obtain the Id of the first one')
		.get('https://todo.ly/api/projects.json')
		.expectStatus(200)
		
		.afterJSON(function(projectData){

			var projectId1 = projectData[0].Id;
			var projectId2 = projectData[1].Id;

			frisby.create('Create a new item in the selected project')
			.post('https://todo.ly/api/items.json', {
				Content: "My Test Item Move",
				ProjectId: projectId1
			})
			.expectStatus(200)
			.expectJSON({
				Content: "My Test Item Move",
				ProjectId: projectId1
			})

			.afterJSON(function(itemData){

				itemId = itemData.Id;

				frisby.create('Verify the item is listed in the project where we have created it')
				.get('https://todo.ly/api/projects/' + projectId1 + '/items.json')
				.expectStatus(200)
				.expectJSON('?', {
					Id: itemId,
					ProjectId: projectId1
				})
				.toss()

				frisby.create('Move Item to the other project')
				.put('https://todo.ly/api/items/' + itemId + '.json', {
					ProjectId: projectId2
				})
				.expectStatus(200)
				.expectJSON({
					ProjectId: projectId2
				})
				.toss()

				frisby.create('Verify the item is listed in the second project ater moving it')
				.get('https://todo.ly/api/projects/' + projectId2 + '/items.json')
				.expectStatus(200)
				.expectJSON('?', {
					Id: itemId,
					ProjectId: projectId2
				})
				.toss()
			
				frisby.create('Delete created item')
				.delete('https://todo.ly/api/items/' + itemId + '.json')
				.expectStatus(200)
				.expectJSON({ 
					Deleted: true 
				})
				.toss()

			})
			.toss()

		})
		.toss()

	})
	.afterJSON(function(data){
		
		frisby.globalSetup({
			request: {
				headers: {
					token: data.TokenString
				},
			json: true
			//inspectOnFailure: true

			}
		})
	
		frisby.create('Get all projects and obtain the Id of the second one')
		.get('https://todo.ly/api/projects.json')
		.expectStatus(200)
		
		.afterJSON(function(projectData){

			projectId = projectData[1].Id;

			frisby.create('Create a new item in the selected project and verify DueDateTime is null')
			.post('https://todo.ly/api/items.json', {
				Content: "My Test Item Next",
				ProjectId: projectId
			})
			.expectStatus(200)
			.expectJSON({
				Content: "My Test Item Next",
				ProjectId: projectId
			})

			.afterJSON(function(itemData){

				itemNextId = itemData.Id;
				dueDateItem = new Date().getTime() + 86400000;
				dueDateTime = '/Date(' + dueDateItem + ')/';
				expect(itemData.DueDateTime).toBe(null);

				frisby.create('Update Due Date Time with a future date')
				.put('https://todo.ly/api/items/' + itemNextId + '.json', {
					DueDateTime: dueDateTime
				})
				.expectStatus(200)

				.afterJSON(function(updatedItem){
					expect(updatedItem.DueDateTime).not.toBe(null);
				})

				.toss()

				frisby.create('Obtain Id for Next Filter')
				.get('https://todo.ly/api/filters.json')
				.expectStatus(200)

				.afterJSON(function(filterList){
				
					for (var i = 0; i < filterList.length; i++) {
						if (filterList[i].Content == "Next") {
							nextId = filterList[i].Id
						}
					}

					frisby.create('Verify Today filter includes the test item')
					.get('https://todo.ly/api/filters/' + nextId + '/items.json')
					.expectStatus(200)
					.expectJSON('?', {
						Content: "My Test Item Next"
					})
					.afterJSON(function(data){

						frisby.create('Delete created item')
						.delete('https://todo.ly/api/items/' + itemNextId + '.json')
						.expectStatus(200)
						.expectJSON({ 
							Deleted: true 
						})
						.toss()

					})
					.toss()

				})
				.toss()

			})
			.toss()

		})
		.toss()

	})
var frisby = require('frisby');

// 1. Smoke test
frisby.globalSetup({
    request: {
        //proxy: 'http://172.20.240.5:8080/',
        headers: {
            Authorization: 'Basic ZXN0aGVyLnlvbDA2QGdtYWlsLmNvbTphZ3VzdGluPzA2'
        },
        json: true,
        inspectOnFailure: true
    }
});
//1.1 Verify Get List filters is executed.
frisby.create('getListFilterExecuted')
    .get('https://todo.ly/api/filters.json')
    .expectStatus(200)


    .toss();
// 1.2 smoke test: Get user is executed without problem
frisby.create('getUserExecuted')
    .get('https://todo.ly/api/user.json')
    .expectStatus(200)


    .toss();


//1.3 Verify project can be deleted.
var request = {
Пример #11
0
describe("MathML Cloud API features", function() {

	// Global setup for all tests
	frisby.globalSetup({
	  request: {
	    headers:{'Accept': 'application/json'},
	    inspectOnFailure: true,
        baseUri: base_url
	  }
	});

	//---- POST /user
	frisby.create("Valid User")
        .post('/user', {
            username : randomUsername() + "@benetech.org",
            password : '******',
            firstName: 'Spec',
            lastName: 'Valid',
            termsOfService: true
        }).
        afterJSON(function(json) {
        	//---- GET /myFeedback
		    //Verify that the newly created user has no feedback.
		    frisby.create("Get My feedback for user with no feedback")
		    	.get("/myFeedback?access_token=" + json.access_token)
		    	.expectStatus(200)
		    	.expectJSON({})
		    	.toss();
		})
        .toss();

	//---- POST /feedback
	// First create an equation that can be given feedback
	frisby.create("Set up equation for feedback")
		.post('/equation', {
			mathType : 'AsciiMath',
			math : 'a^2+b^2=c^2',
			description : 'true',
			svg : 'true'
		})
		//Then, create a user feedback is from.
		.afterJSON(function(equation) {
			frisby.create("Valid User for feedback")
			.post('/user', {
            	username : randomUsername() + "@benetech.org",
            	password : '******',
            	firstName: 'Spec',
            	lastName: 'Valid',
            	termsOfService: true
        	})
        	.afterJSON(function(user) {
				frisby.create("Post feedback")
					.post('/equation/' + equation.id + '/feedback', {
						comments : 'Testing API call',
						access_token: user.access_token
					})
					.expectStatus(200)
					.expectHeaderContains("content-type", "application/json")
					.expectJSON({
						comments : 'Testing API call',
						equation : equation.id,
					})
					.afterJSON(function(json) {
						//Verify we have some feedback for the user.
						frisby.create("Feedback for user")
						.get('/myFeedback?access_token=' + user.access_token)
						.expectStatus(200)
						.expectJSONTypes('feedback.?', {
							components: Array,
							equation: Object,
							submittedBy: String
						})
						.toss()
					})
				.toss();
			}).toss()
		})
		.toss();

	//---- POST /equation
	frisby.create("Convert ASCII math")
		.post('/equation', {
			mathType : 'AsciiMath',
			math : 'a^2+b^2=c^2',
			description : 'true'
		})
		.expectStatus(200)
		.expectHeaderContains("content-type", "application/json")
		.expectJSON("components.?", {
			format : "description",
			source : 'a squared plus b squared equals c squared'
		})
		.afterJSON(function(json) {
			//---- GET /equation/{id}
			frisby.create("Get equation")
				.get('/equation/' + json.id)
				.expectStatus(200)
				.expectHeaderContains("content-type", "application/json")
				.expectJSON("components.?", {
					format : "description",
				})
				.toss();
		})
		.afterJSON(function(json) {
			//---- GET /component/{id}
			frisby.create("Get component")
				.get('/component/' + json.components[0].id)
				.expectStatus(200)
				.expectHeaderContains("content-type", "text/html")
				.expectBodyContains('a squared plus b squared equals c squared')
				.toss();
		})
		.toss();

	// Set up the HTML5 file posting
	var html5Path = path.resolve(__dirname, './data/sample-math.html');
	var form = new FormData();
	form.append('outputFormat', 'svg');
	form.append('html5', fs.createReadStream(html5Path), {
		// we need to set the knownLength so we can call  form.getLengthSync()
		knownLength: fs.statSync(html5Path).size
	});

	//---- POST /html5
	frisby.create("Post HTML5")
		.post('/html5',
			form,
			{
			    json: false,
			    headers: {
			      'content-type': 'multipart/form-data; boundary=' + form.getBoundary(),
			      'content-length': form.getLengthSync()
			    },
			}
		)
		.expectStatus(202)
		.expectHeaderContains("content-type", "application/json")
		.expectJSON({
			outputFormat : 'svg',
			"status" : 'accepted'
		})
		.afterJSON(function(json) {
			//---- GET /html5/{id}
			frisby.create("Get HTML5 resource")
				.get('/html5/' + json.id)
				.expectStatus(200)
				.expectHeaderContains("content-type", "application/json")
				.expectJSON( {
					filename : "sample-math.html",
					outputFormat : "svg",
				})
				.toss();
		})
		.afterJSON(function(json) {
			//---- GET /html5/{id}/output
			frisby.create("Get HTML5 output")
				.get('/html5/' + json.id + '/output')
				.expectStatus(200)
				.expectHeaderContains("content-type", "text/html")
				.toss();
		})
		.afterJSON(function(json) {
			//---- GET /html5/{id}/source
			frisby.create("Get HTML5 source")
				.get('/html5/' + json.id + '/source')
				.expectStatus(200)
				.expectHeaderContains("content-type", "text/html")
				.toss();
		})
		.toss();
});
Пример #12
0
var testJpgPath = path.resolve(__dirname, 'resources/test.jpg');

var pngImageData = new FormData();
pngImageData.append('image', fs.createReadStream(testPngPath), {
    knownLength: fs.statSync(testPngPath).size
});

var jpgImageData = new FormData();
jpgImageData.append('image', fs.createReadStream(testJpgPath), {
    knownLength: fs.statSync(testJpgPath).size
});

frisby.globalSetup({
    request: {
        headers: {
            'X-Device-Id': 'TEST_DEVICE_UUID'
        }
    }
});

var images = [];
frisby.create('Upload a test image1')
    .addHeader('content-type', 'multipart/form-data; boundary=' + pngImageData.getBoundary())
    .addHeader('content-length', pngImageData.getLengthSync())
    .post(IMAGES_API_ENDPOINT, pngImageData)
    .expectStatus(200)
    .afterJSON(function (json) {
        images.push(json.image);

        frisby.create('Upload a test image2')
            .addHeader('content-type', 'multipart/form-data; boundary=' + jpgImageData.getBoundary())
Пример #13
0
const status = {
	'ok': 200,
	'created': 201,
	'notModified': 304,
	'badRequest': 400,
	'unauthorised': 401,
	'notFound': 404
}

const firstIndex = 0
const single = 1

/*  // globalSetup defines any settigs used for ALL requests */
frisby.globalSetup({
	request: {
		headers: {'Authorization': 'Basic dGVzdHVzZXI6cDQ1NXcwcmQ=','Content-Type': 'application/json'}
	}
})

/* here is a simple automated API call making a GET request. We check the response code, one of the response headers and the content of the response body. After completing the test we call 'toss()' which moves the script to the next test. */
frisby.create('get empty list')
	.get('http://localhost:8080/lists')
	.expectStatus(status.notFound)
	.expectHeaderContains('Content-Type', 'application/json')
	.expectJSON({message: 'no lists found'})
	.toss()

/* in this second POST example we don't know precisely what values will be returned but we can check for the correct data types. Notice that the request body is passed as the second parameter and we need to pass a third parameter to indicate we are passing the data in json format. */
frisby.create('add a new list')
	.post('http://localhost:8080/lists', {'name': 'shopping', 'list': ['Cheese', 'Bread', 'Butter']}, {json: true})
	.expectStatus(status.created)
var frisby = require('frisby');

var testData = require('./testData.json');


frisby.globalSetup({
  request: {
    headers: {
  		  'Authentication': 'facetking',
  		  'Content-Type': 'application/json'
    }
  }
});

// Scenario: Post a new candidate without firstName key
frisby.create(' Post a new candidate without firstName key ')
  .post('https://shielded-river-86069.herokuapp.com/contacts/', testData.noFirstName.data,
  { json: true })
  // Validate response code
  .expectStatus(400).inspectJSON()
  // Validate error message
  .expectJSON(testData.noFirstName.error)
  .toss();

// Scenario: Post a new candidate with empty firstName
frisby.create(' Post a new candidate with empty firstName ')
  .post('https://shielded-river-86069.herokuapp.com/contacts/', testData.firstNameEmpty.data,
  { json: true })
  // Validate response code
  .expectStatus(400).inspectJSON()
  // Validate error message
Пример #15
0
/*
 3. CRUD test cases part 2.
*/
var frisby = require('frisby');

frisby.globalSetup({
    request: {
        /*
         proxy: 'http://172.20.240.5:8080/',*/
        headers: {
            Authorization: 'Basic bGVvLmZjeEBnbWFpbC5jb206bGVvIUAjNDU2'
        },
        json: true,
        inspectOnFailure: true
    }
});

var request = {
    "Content": "ProjectCRUD",
    "Icon": 4
};

 //3.6 Negative veiry a user with the same email cannot be created.

 frisby.create('EmailAlreadyExist')
	.post('https://todo.ly/api/user.json', {
			"Email": "*****@*****.**",
			"FullName": "Luna Test",
			"Password": "******"
	})
			.expectStatus(200)
Пример #16
0
/* jshint esnext: true, asi: true */

var fs = require('fs')
var rewire = require('rewire')
var frisby = require('frisby')
var api = require('../modules/api.js')
var authenticate = rewire('../modules/authenticate.js')

frisby.globalSetup({
	request: {
    headers: {'Authorization': 'Basic cGV0ZXJlOkNoYW5nZU1l','Content-Type': 'application/json'}
  }
})

	// == authenticate test ===
frisby.create('authentication check')
	.post('http://cortexapi.ddns.net:8080/api/authenticate', {"username":"******", "password":"******" }, {json: true})
	.expectStatus(201)
	.toss()
var frisby = require('frisby');
var URL = 'http://localhost:3000/api/v1.0';
var item = 0;
var query = '/?limit=1&offset=0';

frisby.globalSetup({ // globalSetup is for ALL requests 
  request: {
    headers: { 'Authorization': 'Basic Zm1vcmFudGU6Zm1vcmFudGU=' }
  }
});

// test if server is running
frisby.create('Server running')
    .get(URL)
    .expectStatus(200)
    .toss();

// test GET /categories
frisby.create('GET categories')
    .get(URL + '/categories' + query)
    .expectStatus(200)
    .expectHeaderContains('content-type', 'application/json')
    .expectJSONTypes({
        Error: Boolean,
        Message: String,
        Categories: Array
    })
    .expectJSON({
        Error: false,
        Message: 'Success'
    })
Пример #18
0
describe("/orders client", function() {

  var order2 = { 
            cart_id: "54675e8cccabc69141ca2903",
            orderDate: "2014-10-24T22:00:00.000Z",
            items: [
              {
                  "price" : "7.99",
                  "item_type" : "secondo piatto",
                  "name" : "polpettono di tonno in scatola_6431",
                  "attributes" : [ 
                      "tonno", 
                      "pangrattato", 
                      "uova", 
                      "parmigiano"
                  ]
              },

              {
                  "price" : "9.99",
                  "item_type" : "secondo piatto",
                  "name" : "polpettono di tonno in scatola_2533",
                  "attributes" : [ 
                      "tonno", 
                      "pangrattato", 
                      "uova", 
                      "parmigiano"
                  ]
              },

              {
                  "price" : "8.99",
                  "item_type" : "secondo piatto",
                  "name" : "polpettono di tonno in scatola_3712",
                  "attributes" : [ 
                      "tonno", 
                      "pangrattato", 
                      "uova", 
                      "parmigiano"
                  ]
              }
            ],
            note: "Questa è una nota",
            confirmed: false,
            closed: false,
            valid: true,
            total: 32.99
          };

  var server = "http://localhost:3000/";
  var baseRoute = "api";
  var basePath = server+baseRoute;
  var addedMessage =  "Order added to the db!";
  var deletedMessage = "Order removed from the db!";

  // Global setup for all tests
  frisby.globalSetup({
    request: {
      headers:{
        'Accept': 'application/json',
        'Authorization': 'Bearer lRn1zpV6ueMZLGrqqr2d7CmlJYr5WSV5jQhf0PpyARaEfGLxm6xsCC52iGhqjaA3XDLfeWbd8HQlAx1HYiO6tV3foBLNygUv4wFYufEQ6TJQPo5mYskhfyaXVLfTgZ7gyxpyjAS7V8yP9lwnNZ5ljcEt6sjgISHhtRUjwc20XpdepRKJn3PdnyfKWKGWMqyBc8kBqRiIZZQQtfiKqlCXaeR5mc8Xba6pCG24LgTPSfUa42Lf6IHTCAiHkU7YxQTD'
      },
      inspectOnFailure: true
    }
  });

  //GET ORDERS
  frisby.create('Get Orders')
    .get(basePath+'/orders')
    // .auth('edo', 'edo')
    .expectStatus(401)
  .toss();

  //POST ORDER
  frisby.create('Post Order')
    .post(basePath+'/orders', order2)
    .expectStatus(200)
    .expectHeaderContains('content-type', 'application/json')
    .expectJSON({
       message: addedMessage,
       data: order2
     })
    // .inspectJSON(function(json) {})
    .afterJSON(function(json) {

      //GET ORDER
      frisby.create('Get Order')
        .get(basePath+'/orders/'+json.data._id)
        .expectStatus(401)
      .toss();

      //GET USER ORDER
      frisby.create('Get Order')
        .get(basePath+'/orders/user/'+json.data._id)
        .expectStatus(200)
        .expectHeaderContains('content-type', 'application/json')
        .expectJSONTypes('0', {
            cart_id: String,
            date: String,
            orderDate: String,
            items: function(val) { expect(val).toBeTypeOrNull(Array); },
            userId: String,
            note: String,
            confirmed: Boolean,
            closed: Boolean,
            valid: Boolean
        })
        .expectJSON('*', order2)
      .toss();

      //GET USER ORDER
      frisby.create('Get Order')
        .get(basePath+'/orders/user/list/all')
        .expectStatus(200)
        .expectHeaderContains('content-type', 'application/json')
        .expectJSONTypes('0', {
            cart_id: String,
            date: String,
            orderDate: String,
            items: function(val) { expect(val).toBeTypeOrNull(Array); },
            userId: String,
            note: String,
            confirmed: Boolean,
            closed: Boolean,
            valid: Boolean
        })
        .expectJSON('*', order2)
      .toss();

      // PUT ORDER
      frisby.create('Put Order')
        .put(basePath+'/orders/'+json.data._id, { "valid": false })
        .expectStatus(401)
      .toss();

      })
  .toss();

});
	.afterJSON(function(data){
		
		frisby.globalSetup({
			request: {
				headers: {
					token: data.TokenString
				},
			json: true
			//inspectOnFailure: true

			}
		})
	
		frisby.create('Get all projects and obtain the Id of the first one')
		.get('https://todo.ly/api/projects.json')
		.expectStatus(200)
		
		.afterJSON(function(projectData){

			projectId = projectData[0].Id;

			frisby.create('Create a new item in the selected project and verify Due Date is empty')
			.post('https://todo.ly/api/items.json', {
				Content: "My Test Item DueDate",
				ProjectId: projectId
			})
			.expectStatus(200)
			.expectJSON({
				Content: "My Test Item DueDate",
				ProjectId: projectId
			})

			.afterJSON(function(itemData){

				itemId = itemData.Id;
				dueDateItem = new Date().getTime();
				dueDateTime = '/Date(' + dueDateItem + ')/';
				expect(itemData.DueDate).toBe("");
				expect(itemData.DueDateTime).toBe(null);

				frisby.create('Update Due Date Time and verify Created Date and Last Updated Date are not the same')
				.put('https://todo.ly/api/items/' + itemId + '.json', {
					DueDateTime: dueDateTime
				})
				.expectStatus(200)

				.afterJSON(function(updatedItem){
					expect(updatedItem.CreatedDate).not.toEqual(updatedItem.LastUpdatedDate);
					expect(updatedItem.DueDate).not.toBe("");
					expect(updatedItem.DueDateTime).not.toBe(null);
				})

				.toss()
			
				frisby.create('Delete created item')
				.delete('https://todo.ly/api/items/' + itemId + '.json')
				.expectStatus(200)
				.expectJSON({ 
					Deleted: true 
				})
				.toss()

			})
			.toss()

		})
		.toss()

	})
var frisby = require('frisby');

// These tests are for testing paymill create API
var serverDetails = {
"url": "https://api.paymill.com/v2.1/clients/",
"firstTestemail":"*****@*****.**",


};
//Please paste your Basic \u003CYOUR-BASE64-ENCODED-PRIVATE-API-KEY-WITH-TRAILING-COLON\u003E below 
frisby.globalSetup({ 
  request: {
    headers: { 'Authorization': 'Basic \u003CYOUR-BASE64-ENCODED-PRIVATE-API-KEY-WITH-TRAILING-COLON\u003E' }
  }
});
frisby.create("This is a clean up operation")
        .get("https://api.paymill.com/v2.1/clients/")
        
        .afterJSON(function(response){
        var x =response.data_count;
        console.log(x)
        for(var i =0;i<x;i++){
            frisby.create("This is a clean up operation")
                    
                  .delete(serverDetails.url+response.data[i].id)
        .toss()
        }
        }).toss();
        
        
        
Пример #21
0
var frisby = require('frisby');

frisby.globalSetup({
	request: {
		proxy: '',
		headers: {
			Token: 'fee9787b3fb24573be80bbd505f9557b'
		},
		json: true,
		inspectOnFailure: true
	}
	
});

var editUser = {
		FullName: "Vania Test"

};

frisby.create('Is authenticated, Todo.ly')
	.get('https://todo.ly/api/authentication/isauthenticated.json')
		.expectStatus(200)
		.afterJSON(function(data){
			expect(data).toBe(true);
		})
.toss();
frisby.create('Update user created, Todo.ly')
	.post('https://todo.ly/api/user/0.json', editUser)
		.expectStatus(200)
		.expectJSON({
			Email:"*****@*****.**",
Пример #22
0
// vim: tabstop=2:softtabstop=2:shiftwidth=2 
// ./node_modules/.bin/jasmine-node . 
var frisby = require('frisby');
var util   = require('util');

var baseURL;
if (typeof process.env.API_BASE_URL != 'undefined') {
	baseURL = process.env.API_BASE_URL;
} else {
	baseURL = "http://api.dev.joind.in:8080";
}

frisby.globalSetup({ // globalSetup is for ALL requests
  request: {
    headers: { 'Content-type': 'application/json' }
  }
});

frisby.create('Initial discovery')
  .get(baseURL)
  .expectStatus(200)
  .expectHeader("content-type", "application/json; charset=utf8")
  .expectJSON({
    'events'          : baseURL + '/v2.1/events',
    'hot-events'      : baseURL + '/v2.1/events?filter=hot',
    'upcoming-events' : baseURL + '/v2.1/events?filter=upcoming',
    'past-events'     : baseURL + '/v2.1/events?filter=past',
    'open-cfps'       : baseURL + '/v2.1/events?filter=cfp'
  })

  .afterJSON(function(apis) {
Пример #23
0
var frisby = require('frisby');

var URL = 'http://api.mysite.com/';

frisby.globalSetup({ // globalSetup is for ALL requests
  request: {
    headers: {'version':'1.0' }
  }
});


frisby.create('Post topic')
    .post('http://api.mysite.com/topics', 
    {
        title:"post test",
        content:"what a wonderful world!",
        node_id:1,
    })
    .expectStatus(200)
    .expectJSON ({
        data:{
            kind:"topic",
            items:{
                title:"post test",
            }    
        }
    }) 
    .afterJSON(function(topic){
        console.log(topic); 
    })
.toss();
Пример #24
0
var frisby = require('frisby');

var URL = 'http://localhost:3000/';

frisby.globalSetup({
  request: {
    headers: { 'X-Auth-Token': 'fa8426a0-8eaf-4d22-8e13-7c1b16a9370c' }
  }
});

frisby.create('Get home')
  .get(URL)
  .expectStatus(200)
  .expectHeaderContains('content-type', 'application/json')
  .expectJSONTypes({
    o: Object,
    m: String,
    s: Number
  })
  .expectJSON({'o':{},'m':'We are hiring!!!','s':0})
  .toss();
Пример #25
0
var frisby = require('frisby');

frisby.globalSetup({
	request: {
		headers: {
				Authorization: 'Basic bGltYmVydC5hcmFuZGlhQGdtYWlsLmNvbTpDb250cm9sMTIz'
			},
			json: true
	}
});

var newProject = {
	"Content": "Project with 1 item1",
	"Icon": 4
};

frisby.create ('create project todo.ly')
  .post ('https://todo.ly/api/projects.json',newProject)
    .inspectJSON()
    .expectStatus(200)
	.expectJSON(newProject)
	.expectJSONTypes({
			"Content": String,
			"Icon": Number
		})			
    .toss();	
Пример #26
0
// Test suite for VEGAPI - users
//
var test = require('frisby');
var app = process.env.VG_APP;
var host = (app || 'sample') + '.vegapi.org:' + (parseInt(process.env.VG_PORT, 10) || 8080);
var URL = 'http://' + host;
var auth = '';
if (app) {
  auth = new Buffer(app + ':' + process.env.VG_KEY).toString('base64');
}

test.globalSetup({
  request: {
    headers: {
      'Host': host,
      'Authorization': 'BASIC ' + auth,
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    }
  }
});

var company = require('../resources/company1');
var user1 = require('../resources/user1');
var user2 = require('../resources/user2');

test.create('Create a company to support user tests')
  .post(URL + '/', company, {json: true})
  .expectStatus(201)
  .expectHeaderContains('Location', '/')
  .expectJSON({
    _data: {
Пример #27
0
    'Geografia',
    'Biologia',
    'Química',
    'Física',
    'Filosofia',
    'Inglês',
    'Literatura',
    'Redação',
    'História',
    'Matemática',
    'Alquimia',
    'Agroquímica',
    'Astroquímica',
    'Bioquímica',
    'Álgebra',
    'Análise',
    'Cálculo',
    'Geomática',
    'Inteligência Artificial',
    'Interação humano-computador',
    'Linguagens de Programação',
    'Mecatrônica',
    'Programação',
    'Redes',
    'Robótica',
    'Sistemas de Informação'
];

frisby.globalSetup(options);

module.exports.frisby = frisby;
Пример #28
0
var frisby = require('frisby');

var apiUrl = 'http://ts.langl.eu';

frisby.globalSetup({
  request: {
    headers: { 'x-device': 'app' }
  }
});

frisby.create('Get Status of userApi')
  .get(apiUrl + '/userApi')
  .expectStatus(200)
  .expectHeaderContains('content-type', 'application/json')
.toss();
	.afterJSON(function(data){
		
		frisby.globalSetup({
			request: {
				headers: {
					token: data.TokenString
				},
			json: true
			//inspectOnFailure: true

			}
		})
	
		frisby.create('Create a new project and verify it has no children')
		.post('https://todo.ly/api/projects.json', newProject)
		.expectStatus(200)

		.afterJSON(function(projectData){

			projectId = projectData.Id;
			expect(projectData.Children.length).toEqual(0);

			frisby.create('Create a sub project in the project we just created')
			.post('https://todo.ly/api/projects.json', {
				Content: "Test Sub Project Done Items",
				Icon: 6,
				ParentId: projectId
			})
			.expectStatus(200)
			.expectJSON({
				Content: "Test Sub Project Done Items",
				Icon: 6,
				ParentId: projectId
			})

			.afterJSON(function(subProjectData){

				subProjectId = subProjectData.Id
				parentProjectId = subProjectData.ParentId

				frisby.create('Create a new done item in the subproject')
				.post('https://todo.ly/api/items.json', {
					Content: "My Test Done Item 1",
					Checked: true,
					ProjectId: subProjectId
				})
				.expectStatus(200)
				.expectJSON({
					Content: "My Test Done Item 1",
					Checked: true,
					ProjectId: subProjectId
				})

				.toss()

				frisby.create('Create a new done item in the subproject')
				.post('https://todo.ly/api/items.json', {
					Content: "My Test Done Item 2",
					Checked: true,
					ProjectId: subProjectId
				})
				.expectStatus(200)
				.expectJSON({
					Content: "My Test Done Item 2",
					Checked: true,
					ProjectId: subProjectId
				})

				.toss()

				frisby.create('Create a new item in the subproject')
				.post('https://todo.ly/api/items.json', {
					Content: "My Test Item 1",
					ProjectId: subProjectId
				})
				.expectStatus(200)
				.expectJSON({
					Content: "My Test Item 1",
					ProjectId: subProjectId
				})

				.toss()

				frisby.create('Verify only one item exists in the subproject')
				.get('https://todo.ly/api/projects/' + subProjectId + '/items.json')
				.expectStatus(200)
				.afterJSON(function(itemsData){
					expect (itemsData.length).toBe(1)
				})
				.toss()

				frisby.create('Verify two done items exist in the subproject')
				.get('https://todo.ly/api/projects/' + subProjectId + '/doneitems.json')
				.expectStatus(200)
				.afterJSON(function(doneItemsData){
					expect (doneItemsData.length).toBe(2)
				})
				.toss()

				frisby.create('Delete created parent project')
				.delete('https://todo.ly/api/projects/' + parentProjectId + '.json')
				.expectStatus(200)
				.expectJSON({ 
					Deleted: true 
				})
				.toss()

			})
			.toss()

		})
		.toss()

	})
Пример #30
0
const 
    app = require("../app/index"),
    db = require("../app/persistence"),
    frisby = require("frisby"),
    uuid = require("uuid-v4"),
    logger = require("../app/log")("api.test"),
    config = require("../app/config"),
    baseUrl = "http://localhost:8080"
;

frisby.globalSetup({
    request: {
        headers: {
            'Authorization': 'Basic ' + Buffer.from(`${config.admin.user}:${config.admin.pass}`).toString('base64'),
        }
    }
})

beforeAll( async () => {
    await app.startPromise
})

afterAll( () =>{
    app.server.close()
})

test ("Health check", async () => {
    logger.info("Calling health")
    return frisby.get(`${baseUrl}/health`)
        .expect('status',200)
        .expect('json','status','ok')