コード例 #1
0
ファイル: feed_read_spec.js プロジェクト: ctindel/reader
            .afterJSON(function getSecondFeed(res2) {
                frisby.create('GET second feed for user ' + user.email)
                    .get(tc.url + '/feeds/' + res1.feeds[1]._id + '/entries?unreadOnly=false')
                    .auth(user.sp_api_key_id, user.sp_api_key_secret)
                    .expectStatus(200)
                    .expectHeader('Content-Type', 'application/json; charset=utf-8')
                    .expectJSONLength('feed.unreadEntries', 0)
                    // We add 1 to unreadCount because the previous test
                    // case (feed_entry_read_spec.js) had marked a single 
                    // entry as read already
                    .expectJSONLength('feed.readEntries', res1.feeds[1].unreadCount+1)
                    .toss()

                frisby.create('GET feed list again for user ' + user.email)
                    .get(tc.url + '/feeds')
                    .auth(user.sp_api_key_id, user.sp_api_key_secret)
                    .expectStatus(200)
                    .expectHeader('Content-Type', 'application/json; charset=utf-8')
                    .expectJSON('feeds.1', {unreadCount : 0})
                    .toss()
            })
コード例 #2
0
		.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();
		})
コード例 #3
0
ファイル: test_spec.js プロジェクト: Foaly/MME2
 .afterJSON(function(json) {
     var oldBook = json;
     frisby.create('Get next random book')
         .get('http://localhost:8080/api/v1/books?limit=1&skip=1')
         .auth('user', 'password')
         .expectStatus(200)
         .expectHeaderContains('content-type', 'application/json')
         .afterJSON(function(json) {
             expect(oldBook).not.toBe(json);
         })
         .toss();
 })
コード例 #4
0
 function () {
     brand.name = brand.name.toUpperCase();
     frisby.create('Create brand')
         .post(url, brand, {
             json: true
         })
         .expectStatus(201)
         .expectHeaderContains('Content-Type', 'application/json')
         .inspectJSON()
         .expectJSON(brand)
         .toss();
 });
コード例 #5
0
ファイル: profile_spec.js プロジェクト: daveWid/denizen
			.afterJSON(function(response){

				frisby.create('Access a users own profile')
					.get(URL + '/me')
					.addHeader('Authorization', 'Bearer ' + token)
					.expectStatus(200)
					.expectJSON('user', {
						id: 1
					})
				.toss();

			})
コード例 #6
0
ファイル: test_spec.js プロジェクト: Foaly/MME2
 .after(function(err, res, body) {
     frisby.create('Try to delete same book again')
         .delete('http://localhost:8080/api/v1/books/' + bookId)
         .auth('user', 'password')
         .expectStatus(404)
         .expectJSON({
             type: 'error',
             statusCode: 404,
             msg: 'Requested resource not found'
         })
         .toss();
 })
コード例 #7
0
 function subOneFeedSecondUser(callback) {
 	var user = TEST_USERS[1];
 	frisby.create('PUT Add one feed sub for second user ' + user.email)
             .put(tc.url + '/feeds/subscribe',
                  {'feedURL' : nycEaterFeedURL})
             .auth(user.sp_api_key_id, user.sp_api_key_secret)
             .expectStatus(201)
             .expectHeader('Content-Type', 'application/json; charset=utf-8')
             .expectJSONLength('user.subs', 1)
             .toss()
 	callback(null);
}
コード例 #8
0
		.afterJSON(function(data){
			var projectID = data.Id
			frisby.create('Add Done Item')
				.post('https://todo.ly/api/items.json', {
					"Content": "New Item from frisby",
					"ProjectId": projectID
				})
				.expectStatus(200)
				.expectJSON({
					"Content": "New Item from frisby"
				})
				.afterJSON(function(data){
					var itemID = data.Id
					frisby.create('Update Item to Done')
						.put('https://todo.ly/api/items/'+ itemID +'.json',
						{
						"Content": "Done Item from frisby",
						"Checked": true
						}
						)
						.expectStatus(200)
						.expectJSON({
							"Content": "Done Item from frisby",
							"Checked": true
						})
					.toss();	
				})
			.toss();
			
			frisby.create('Add not-done Item')
				.post('https://todo.ly/api/items.json', {
					"Content": "New Item from frisby",
					"ProjectId": projectID
				})
				.expectStatus(200)
				.expectJSON({
					"Content": "New Item from frisby",
				})
			.toss();
		})
コード例 #9
0
ファイル: mail_spec.js プロジェクト: carriercomm/CacoCloud
                    .afterJSON(function (mailtrap) {
                        frisby.create('API: Checking mail with mailtrap [2/2]')
                            .get(config.mailtrap.getApiUrlMessage(mailtrap[0].message.id))
                            .expectStatus(200)
                            .expectJSONTypes({
                                message: {
                                    id: String,
                                    from: String,
                                    title: String,
                                    created_at: String,
                                    recipients: [Object],
                                    source: String
                                }
                            })
                            .expectBodyContains(body)
                            .toss();

                        frisby.create('API: Edit the newly added mail account')
                            .put(url + '/account/' + id, {
                                name: 'Mail Test Account'
                            }, {json: true})
                            .expectHeaderContains('content-type', 'application/json')
                            .expectStatus(200)
                            .expectJSON({
                                status: 200,
                                response: id
                            })
                            .afterJSON(function (api) {
                                frisby.create('API: Delete the newly added mail account')
                                    .delete(url + '/account/' + id)
                                    .expectHeaderContains('content-type', 'application/json')
                                    .expectStatus(200)
                                    .expectJSON({
                                        status: 200,
                                        response: id
                                    })
                                    .toss();
                            })
                            .toss();
                    })
コード例 #10
0
ファイル: clean.js プロジェクト: nicholasc69/datacollector
 pipelineListJSON.forEach(function(pipelineInfo) {
   frisby.create('Should be able to delete pipeline configuration.')
     .delete(browser.baseUrl + 'rest/v1/pipeline/' + pipelineInfo.name, {}, {
       headers:  {
         "Content-Type": "application/json",
         "Accept": "application/json",
         "Cookie": cookie,
         "X-Requested-By": "CSRF"
       }
     })
     .expectStatus(200)
     .toss();
 });
コード例 #11
0
ファイル: userApiSpec.js プロジェクト: martinsula/juice-shop
    .afterJSON(function (user) {
        frisby.create('POST login existing user')
            .post(REST_URL + '/user/login', {
                email: '*****@*****.**',
                password: '******'
            }, {json: true})
            .expectStatus(200)
            .expectHeaderContains('content-type', 'application/json')
            .expectJSONTypes({
                token: String
            })
            .afterJSON(function(auth) {
                frisby.create('GET password change with recognized authorization token')
                    .get(REST_URL + '/user/change-password?new=foo&repeat=foo')
                    .addHeaders({ 'Authorization': 'Bearer ' + auth.token })
                    .expectStatus(200)
                    .toss();
    }).toss();

        frisby.create('GET existing user by id')
            .addHeaders(authHeader)
            .get(API_URL + '/Users/' + user.data.id)
            .expectStatus(200)
            .after(function() {
                frisby.create('PUT update existing user')
                    .addHeaders(authHeader)
                    .put(API_URL + '/Users/' + user.data.id, {
                        email: '*****@*****.**'
                    })
                    .expectStatus(200)
                    .after(function() {
                        frisby.create('DELETE existing user is forbidden via API even when authenticated')
                            .addHeaders(authHeader)
                            .delete(API_URL + '/Users/' + + user.data.id)
                            .expectStatus(401)
                            .toss();
                    }).toss();
            }).toss();
    }).toss();
コード例 #12
0
 .after(function (err, res, body) {
     var track_uri = res.headers.location;
     frisby.create('Check Hosts for the event')
         .get(track_uri)
         .expectStatus(200)
         .expectJSON('hosts', [
             {"host_name" : "A test user for events"},
             {"host_name"   : hostToAdd.full_name,
                 "host_uri" : hostToAdd.uri
             }
         ])
         .toss();
 })
コード例 #13
0
ファイル: intro_spec.js プロジェクト: spencerroh/Undercity
            .afterJSON(function (json) {
                images.push(json.image);

                frisby.create('Create a introduction of shop')
                    .post(INTRO_API_ENDPOINT, {
                        Title: '아삭한 이연복 탕수육',
                        Description: '겁나 맛난 이연복 탕수육 먹으로 오세욜!',
                        Images: images
                    }, {json: true})
                    .inspectBody()
                    .expectStatus(200)
                    .toss();
            })
コード例 #14
0
ファイル: feed_err_spec.js プロジェクト: ctindel/reader
 .afterJSON(function markEntryRead(res2) {
     frisby.create('PUT mark entry read with wrong feedID for user ' + user.email)
         .put(uri + '/feeds/' + res1.feeds[0]._id + '/entries/' + res2.feed.unreadEntries[0]._id,
              {'read' : 'true'})
         .addHeader('Authorization', 'Bearer ' + user.token)
         .expectStatus(404)
         .expectHeader('Content-Type', 'application/json; charset=utf-8')
         .expectJSON({'error' :
                      'Entry ' + res2.feed.unreadEntries[0]._id
                      + ' is part of feed ' + res1.feeds[1]._id
                      + ' not part of feed ' + res1.feeds[0]._id})
         .toss()
 })
コード例 #15
0
// Send something that should trigger an error
function postBadRecord(record){
  frisby.create('Validation: Enforce mandatory fields when creating')
    .post(url, record, {json: true})
    .expectStatus(422)
    .expectHeaderContains('Content-Type', 'application/json')
    .expectJSON({
      error: {
        name: 'ValidationError',
        details: {
          codes: {
          }}}})
    .toss();
}
コード例 #16
0
 .afterJSON(function (body) {
     frisby.create('Set the value of whoami')
     .get('http://localhost:3001/nodes/' + CLOCK2 + '/start')
     .expectStatus(204)
     .after(function(err, res, body) {
         frisby.create('Check that running = 1')
         .get('http://localhost:3001/nodes/' + CLOCK2 + '/running')
         .expectStatus(200)
         .expectJSON([1])
         .toss()
     })
     .toss()
 })
コード例 #17
0
ファイル: api_read.js プロジェクト: RileyMajor/joindin-api
		.afterJSON(function(evTalks) {
			var talk;
			if(typeof evTalks.talks == 'object') {
				for(var i in evTalks.talks) {
					talk = evTalks.talks[i];
					datatest.checkTalkData(talk);
				}

				if(typeof talk == 'object') {
					// check some comments on the last talk
					frisby.create('Comments on talk ' + talk.talk_title)
						.get(talk.comments_uri + '?resultsperpage=3')
						.expectStatus(200)
						.expectHeader("content-type", "application/json; charset=utf8")
						.afterJSON(function(evTalkComments) {
							if(typeof evTalkComments.comments == 'object') {
								for(var i in evTalkComments.comments) {
									var talkComment = evTalkComments.comments[i];
									datatest.checkTalkCommentData(talkComment);
								}
							}
						}).toss();

					// and in verbose mode
					frisby.create('Comments on talk ' + talk.talk_title + ' (verbose mode)')
						.get(talk.comments_uri + '?resultsperpage=3&verbose=yes')
						.expectStatus(200)
						.expectHeader("content-type", "application/json; charset=utf8")
						.afterJSON(function(evTalkComments) {
							if(typeof evTalkComments.comments == 'object') {
								for(var i in evTalkComments.comments) {
									var talkComment = evTalkComments.comments[i];
									datatest.checkVerboseTalkCommentData(talkComment);
								}
							}
						}).toss();
				}
			}
	}).toss();
コード例 #18
0
ファイル: userApiSpec.js プロジェクト: graywt/juice-shop
         .afterJSON(function(auth) {
             frisby.create('GET own user id and email on who-am-i request')
                 .get(REST_URL + '/user/whoami')
                 .addHeaders({'Authorization': 'Bearer ' + auth.token})
                 .expectStatus(200)
                 .expectHeaderContains('content-type', 'application/json')
                 .expectJSONTypes({
                     id: Number
                 })
                 .expectJSON({
                     email: '*****@*****.**'
                 })
                 .toss();
             frisby.create('GET password change with recognized token as cookie')
                 .get(REST_URL + '/user/change-password?new=foo&repeat=foo')
                 .addHeaders({ 'Cookie': 'token=' + auth.token })
                 .expectStatus(200)
                 .toss();
             frisby.create('GET password change with recognized token as cookie in double-quotes')
                 .get(REST_URL + '/user/change-password?new=foo&repeat=foo')
                 .addHeaders({ 'Cookie': 'token=%22' + auth.token + '%22' })
                 .expectStatus(200)
                 .toss();
             frisby.create('GET existing basket of another user')
                 .addHeaders({'Authorization': 'Bearer ' + auth.token})
                 .get(REST_URL + '/basket/2')
                 .expectStatus(200)
                 .expectHeaderContains('content-type', 'application/json')
                 .expectJSON('data', {
                     id: 2
                 })
                 .toss();
             frisby.create('POST feedback is associated with current user')
                 .addHeaders({'Authorization': 'Bearer ' + auth.token})
                 .post(API_URL + '/Feedbacks', {
                     comment: 'Horst\'s choice award!',
                     rating: 5,
                     UserId: 4
                 }, {json: true})
                 .expectStatus(200)
                 .expectHeaderContains('content-type', 'application/json')
                 .expectJSON('data', {
                     UserId: 4
                 })
                 .toss();
             frisby.create('POST feedback is associated with any passed user id')
                 .addHeaders({'Authorization': 'Bearer ' + auth.token})
                 .post(API_URL + '/Feedbacks', {
                     comment: 'Bender\'s choice award!',
                     rating: 2,
                     UserId: 3
                 }, {json: true})
                 .expectStatus(200)
                 .expectHeaderContains('content-type', 'application/json')
                 .expectJSON('data', {
                     UserId: 3
                 })
                 .toss();
 }).toss();
コード例 #19
0
ファイル: filename_spec.js プロジェクト: bodji/test2
                .afterJSON(function(file) {
                    //Get the file
                    file_id = file.id;
                    file_name = file.fileName

                    frisby.create('Get file')
                        .get(commons.host+'/file/'+upload_id+'/'+file_id+'/'+file_name )
                        .expectStatus(200)
                        .after(function(err, res, body) {
                            expect("Bodji c'est mon copain").toEqual(body);
                         })
                .toss()
                })
コード例 #20
0
        .afterJSON(function(res) {
            frisby.create('Get Firmware List with key ')
                .get('https://localhost:443/dm/v2/client/get_firmware_list?key='+test_ModelName,
                  { strictSSL: false})
                .expectStatus(200)
                .expectHeaderContains('content-type', 'application/json; charset=utf-8')
            .toss()

            frisby.create('Get Firmware List with key empty')
                .get('https://localhost:443/dm/v2/client/get_firmware_list?key=',
                  { strictSSL: false})
                .expectStatus(400)
                .expectHeaderContains('content-type', 'application/json; charset=utf-8')
            .toss()

            frisby.create('Get Firmware List with no such key')
                .get('https://localhost:443/dm/v2/client/get_firmware_list?key=00000000000',
                  { strictSSL: false})
                .expectStatus(400)
                .expectHeaderContains('content-type', 'application/json; charset=utf-8')
            .toss()
        })
コード例 #21
0
 describe('irregardless of job success', function () {
     beforeEach(function (done) {
         
         submitJobDeferred.resolve(testJob);
         
         act(done);
     });
     
     frisby.create('with bad credentials should fail')
         .post(host + '/jobs', null, {
             auth: { user: creds.user+'bad', pass: creds.pass }
         })
         .expectStatus(401)
         .toss();
         
     frisby.create('Non text/plain content-type should fail')
         .post(host + '/jobs', null, {
             body: payload,
             headers: {
                 'content-type': 'application/json'
             },
             auth: { user: creds.user, pass: creds.pass }
         })
         .expectStatus(415) //Unsupported Media Type
         .toss();
     
     frisby.create('Composite plain/text content-type header should succeed (FF behavior)')
         .post(host + '/jobs', null, {
             body: payload,
             headers: {
                 'content-type': 'text/plain; charset=UTF-8'
             },
             auth: { user: creds.user, pass: creds.pass }
         })
         .expectStatus(200)
         .toss();
         
     
 });
コード例 #22
0
ファイル: 5_spec.js プロジェクト: WALL-E/httptables
 function(callback){
   frisby.create('api.t.com-case-5-5')
     .get('http://{httptables}:8000/test/device'.format(config))
     .addHeader('host', 'apis.t.com')
     .addHeader('X-User-ID', 'user_1')
     .expectStatus(200)
     .expectJSON({
       status: 200,
     })
     //.inspectBody()
   .toss();
   callback(null, '7');
 },
コード例 #23
0
ファイル: api_write.js プロジェクト: RileyMajor/joindin-api
function testUnverifiedUserFailsLogin(username, password) {
  frisby.create('Log in')
    .post(baseURL + "/v2.1/token", {
      "grant_type": "password",
      "username": username,
      "password": password,
      "client_id": "0000",
      "client_secret": "1111"
    }, {json:true})
    .expectStatus(403)
    .toss();

}
コード例 #24
0
    .afterJSON(function(data){

        var projectId = data.Id;

         frisby.create('Create a item')
            .post('https://todo.ly/api/items.json', {
                "Content": "ItemCRUD",
                "ProjectId": projectId
            })
            .expectStatus(200)
            .afterJSON(function(data){

                var itemId = data.Id;

                frisby.create('Verify if the item was created in the project selected')
                    .get('https://todo.ly/api/items/' + itemId + '.json')
                    .expectStatus(200)
                    .expectJSON({
                        "Content": "ItemCRUD",
                        "ProjectId": projectId
                    })
                    .toss();

                    frisby.create('Update the item name')
                            .put('https://todo.ly/api/items/' + itemId + '.json', {
                                "Content": "ItemNameRenamed"
                            })
                                .expectStatus(200)
                                .expectJSON({
                                    "Content": "ItemNameRenamed"
                                })
                        .toss();
                frisby.create('Delete the Item created')
                    .delete('https://todo.ly/api/items/' + itemId + '.json')
                    .expectStatus(200)
                    .expectJSON({
                                    "Deleted": true
                                })
                    .toss();

                frisby.create('Delete the Project created')
                    .delete('https://todo.ly/api/projects/' + projectId + '.json')
                    .expectStatus(200)
                    .expectJSON({
                                    "Deleted": true
                                })
                    .toss();   
            })
            .toss();

    })
コード例 #25
0
ファイル: filename_spec.js プロジェクト: bodji/test2
    .afterJSON(function(upload) {
        var upload_id = upload.id;

        for(var file_name in files)
        {

            form = new FormData();
            form.append('file', "Bodji c'est mon copain", {
                  contentType: 'text/plain',
                  filename: file_name
            });


            frisby.create('Post file' + file_name)
                .post(
                    commons.host+'/upload/'+upload_id+'/file',
                    form,
                    {
                        json: false,
                        headers: {
                          'X-UploadToken' : upload.uploadToken,
                          'content-type': 'multipart/form-data; boundary=' + form.getBoundary(),
                          'content-length': form.getLengthSync()
                        }
                    }
                )
                .expectStatus(200)
                .expectJSONTypes('', {
                    'id': String,
                    'fileName': String
                })
                .expectJSON('',{
                    'fileName': files[file_name]
                })
                .afterJSON(function(file) {
                    //Get the file
                    file_id = file.id;
                    file_name = file.fileName

                    frisby.create('Get file')
                        .get(commons.host+'/file/'+upload_id+'/'+file_id+'/'+file_name )
                        .expectStatus(200)
                        .after(function(err, res, body) {
                            expect("Bodji c'est mon copain").toEqual(body);
                         })
                .toss()
                })
            .toss()
        }
      })
コード例 #26
0
TEST_USERS.forEach(function createUser(user, index, array) {
    frisby.create('POST enroll user ' + user.email)
        .post(tc.url + '/user/enroll',
              { 'firstName' : user.fn,
                'lastName' : user.ln,
                'email' : user.email,
                'password' : user.pwd })
        .expectStatus(201)
        .expectHeader('Content-Type', 'application/json; charset=utf-8')
        .expectJSON({ 'firstName' : user.fn,
                      'lastName' : user.ln,
                      'email' : user.email })
        .toss()
});
コード例 #27
0
 .afterJSON(function (json) {
     console.log(json.expires_in);
     console.log(json);
     frisby.create('and now get protected resource with attached bearer token')
         .get(host + '/api/test', {
             headers: { 'Authorization': 'Bearer ' + json.access_token }
         })
         .expectStatus(200)
         .toss();
     frisby.create('and try to get a new access token with our refresh token')
         .post(host + '/token', {
             grant_type: 'refresh_token',
             refresh_token: json.refresh_token,
             client_id: clientId
         })
         .afterJSON(function (json2) {
             //we should receive a new access token
             expect(json.access_token).not.toEqual(json2.access_token);
             //but shouldn't the refresh token remain the same until *it* expires?
             expect(json.refresh_token).toEqual(json2.refresh_token);
         })
         .toss();
 })
コード例 #28
0
function testCreateEventFailsIfNotLoggedIn()
{
  frisby.create('Create event fails if not logged in')
    .post(
      baseURL + "/v2.1/events",
      {},
      {json: true}
    )
    .afterJSON(function(result) {
      expect(result[0]).toContain("You must be logged in");
    })
    .expectStatus(400) // fails as no user token
    .toss();
}
コード例 #29
0
ファイル: api_read.js プロジェクト: RileyMajor/joindin-api
function testAttendeesForEventVerbose(evt) {
	frisby.create('Attendees to ' + evt.name + ' (verbose format)')
			.get(evt.attendees_uri + '?resultsperpage=3&verbose=yes')
		.expectStatus(200)
		.expectHeader("content-type", "application/json; charset=utf8")
		.afterJSON(function(evUsers) {
			if(typeof evUsers.users == 'object') {
				for(var i in evUsers.users) {
					var user = evUsers.users[i];
					datatest.checkVerboseUserData(user);
				}
			}
	}).toss();
}
コード例 #30
0
ファイル: api_read.js プロジェクト: RileyMajor/joindin-api
function testEventCommentsVerbose(evt) {
	frisby.create('Event comments for ' + evt.name + ' (verbose mode)')
		.get(evt.comments_uri + '?resultsperpage=3&verbose=yes')
		.expectStatus(200)
		.expectHeader("content-type", "application/json; charset=utf8")
		.afterJSON(function(evComments) {
			if(typeof evComments.comments == 'object') {
				for(var i in evComments.comments) {
					var comment = evComments.comments[i];
					datatest.checkVerboseEventComment(comment);
				}
			}
	}).toss();
}