Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('POST will send a new IPN message to IPN listener', function(done){
console.log('New subscription from user:', requestForm.payer_email);
request.post('/')
// format application/x-www-form-urlencoded
.type('form')
.send(requestForm)
.expect(function(res){
console.log('POST response body:' + JSON.stringify(res.body));
})
.expect(200, done);
});
test("Owner Account Login - Valid Body - 200 Response", async t => {
const response = await request.post("api/v1.0/authentication/login").send({
workspaceURL: testData.workspaceURL,
emailAddress: testData.emailAddress,
password: testData.password,
keepSignedIn: false
});
t.is(response.status, 200);
t.not(response.body.token, null);
t.is(response.body.keepSignedIn, false);
// Store token for future user
testData.securityToken = `jwt ${response.body.token}`;
});
test("Owner Account Invalid Security Token Login Failure - Invalid Token - 403 Response", async t => {
const response = await request
.post("api/v1.0/authentication/login")
.set("Authorization", "invalid security token")
.send({
authToken: true
});
t.is(response.status, 403);
});
it('Create fakeapp', function (done) {
var data = {
'longName' : 'fakeapp',
'project' : 'test',
'version' : '',
'study': 'fakeapp',
'technicalName' : 'test-fakeapp',
'app' : 'fakeapp'
};
request
.post('/-/v1/instances')
.send(data)
.expect(200, function (err) {
done(err);
});
});
it('Create image', function (done) {
var data = {
'imageName' : 'hello-world',
'versionImage' : 'latest',
'imageHub' : ''
};
request
.post('/-/v1/app')
.send(data)
.expect(200, function (err) {
done(err);
});
});
test("Owner Account Logout - Valid Header - 200 Response", async t => {
const response = await request.post("api/v1.0/authentication/logout").set("Authorization", testData.securityToken);
t.is(response.status, 200);
});
test("Create New Client - Valid Body - 200 Response", async t => {
const response = await request.post("api/v1.0/authentication/register").send({
workspaceURL: testData.workspaceURL,
firstName: testData.firstName,
lastName: testData.lastName,
emailAddress: testData.emailAddress,
password: testData.password,
privacyConsent: testData.privacyConsent,
language: testData.language
});
t.is(response.status, 200);
});
test("Create New Client - Missing Body Content - 403 Response", async t => {
const response = await request.post("api/v1.0/authentication/register");
t.is(response.status, 403);
t.deepEqual(response.body.reason.emailAddress, ["Error: Field cannot be blank."]);
t.deepEqual(response.body.reason.password, ["Error: Field cannot be blank."]);
t.deepEqual(response.body.reason.workspaceURL, ["Error: Field cannot be blank."]);
});
function (cb) {
user.aGrps = undefined
request
.post('/api/v1/users/create')
.set('accesstoken', tdapikey)
.set('Content-Type', 'application/json')
.send(user)
.set('Accept', 'application/json')
.expect(
400,
{
success: false,
error: 'Invalid Group Array'
},
cb
)
},
function (cb) {
.expect(200, "", function() {
request
.post("")
.type("form")
.send({ method: "get", name: "post-file.txt" })
.expect("Content-Type", /^text\/plain/)
.expect(200, "Bye.", function() {
request
.post("")
.type("form")
.send({ method: "delete", name: "post-file.txt" })
.expect("Content-Type", /^text\/plain/)
.expect(200, "", done);
});
});
});