Skip to content

Commit 99e24d7

Browse files
test scripts updated
1 parent d19b1c2 commit 99e24d7

File tree

10 files changed

+233
-431
lines changed

10 files changed

+233
-431
lines changed

tests/alignments.js

Lines changed: 17 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*********************************************************************************
22
* The MIT License (MIT) *
33
* *
4-
* Copyright (c) 2019 KMi, The Open University UK *
4+
* Copyright (c) 2020 KMi, The Open University UK *
55
* *
66
* Permission is hereby granted, free of charge, to any person obtaining *
77
* a copy of this software and associated documentation files (the "Software"), *
@@ -30,17 +30,13 @@
3030
var chai = require('chai');
3131
var chaiHttp = require('chai-http');
3232
var app = require('../apptest.js');
33+
const cfg = require('../config.js');
3334

3435
// Configure chai
3536
chai.use(chaiHttp);
3637
chai.should();
3738
var expect = chai.expect;
3839

39-
let login_details_correct = {
40-
'username': 'ioc@kmi.open.ac.uk',
41-
'password': '10CM00d13b10cKcH@16n'
42-
}
43-
4440
/*
4541
check('id').withMessage('You must include your reference id for the new badge'),
4642
check('title').withMessage('You must include a title for the new badge'),
@@ -94,10 +90,10 @@ let alignment_data_delete = {
9490
var alignmentid = "";
9591

9692
describe("Alignments", () => {
97-
describe("POST /badges/alignments/create with good data", () => {
93+
describe("POST "+cfg.proxy_path+"/alignments/create with good data", () => {
9894
it("sign in and create alignment", (done) => {
9995
chai.request(app)
100-
.post('/badges/users/signin')
96+
.post(cfg.proxy_path+'/users/signin')
10197
.send(login_details_correct)
10298
.end((err, res) => {
10399
res.should.have.status(201);
@@ -107,7 +103,7 @@ describe("Alignments", () => {
107103
let token = res.body.token;
108104

109105
chai.request(app)
110-
.post('/badges/alignments/create')
106+
.post(cfg.proxy_path+'/alignments/create')
111107
.set('Authorization', token)
112108
.send(alignment_data_correct)
113109
.end((err, res) => {
@@ -137,10 +133,10 @@ describe("Alignments", () => {
137133
}).timeout(100000);
138134
});
139135

140-
describe("POST /badges/alignments/update with good data", () => {
136+
describe("POST "+cfg.proxy_path+"/alignments/update with good data", () => {
141137
it("should update an alignment record", (done) => {
142138
chai.request(app)
143-
.post('/badges/users/signin')
139+
.post(cfg.proxy_path+'/users/signin')
144140
.send(login_details_correct)
145141
.end((err, res) => {
146142
res.should.have.status(201);
@@ -150,7 +146,7 @@ describe("Alignments", () => {
150146
let token = res.body.token;
151147

152148
chai.request(app)
153-
.post('/badges/alignments/update')
149+
.post(cfg.proxy_path+'/alignments/update')
154150
.set('Authorization', token)
155151
.send(alignment_data_update)
156152
.end((err, res) => {
@@ -175,10 +171,10 @@ describe("Alignments", () => {
175171
}).timeout(100000);
176172
});
177173

178-
describe("GET /badges/alignments/id/:id - to get previously created badge", () => {
174+
describe("GET "+cfg.proxy_path+"/alignments/id/:id - to get previously created badge", () => {
179175
it("sign in and get alignment by id", (done) => {
180176
chai.request(app)
181-
.post('/badges/users/signin')
177+
.post(cfg.proxy_path+'/users/signin')
182178
.send(login_details_correct)
183179
.end((err, res) => {
184180
res.should.have.status(201);
@@ -188,7 +184,7 @@ describe("Alignments", () => {
188184
let token = res.body.token;
189185

190186
chai.request(app)
191-
.get('/badges/alignments/id/'+alignmentid)
187+
.get(cfg.proxy_path+'/alignments/id/'+alignmentid)
192188
.set('Authorization', token)
193189
.end((err, res) => {
194190

@@ -212,10 +208,10 @@ describe("Alignments", () => {
212208
}).timeout(100000);
213209
});
214210

215-
describe("GET /badges/alignments/list", () => {
211+
describe("GET "+cfg.proxy_path+"/alignments/list", () => {
216212
it("sign in and get a list of all alignments for the current user", (done) => {
217213
chai.request(app)
218-
.post('/badges/users/signin')
214+
.post(cfg.proxy_path+'/users/signin')
219215
.send(login_details_correct)
220216
.end((err, res) => {
221217
res.should.have.status(201);
@@ -225,7 +221,7 @@ describe("Alignments", () => {
225221
let token = res.body.token;
226222

227223
chai.request(app)
228-
.get('/badges/alignments/list')
224+
.get(cfg.proxy_path+'/alignments/list')
229225
.set('Authorization', token)
230226
.end((err, res) => {
231227

@@ -243,173 +239,10 @@ describe("Alignments", () => {
243239
});
244240

245241
/*
246-
describe("POST /badges/create with incorrect issuer id", () => {
247-
it("login and return a 404", (done) => {
248-
chai.request(app)
249-
.post('/badges/users/signin')
250-
.send(login_details_correct)
251-
.end((err, res) => {
252-
res.should.have.status(201);
253-
res.body.should.be.a('object');
254-
res.body.should.have.property('token');
255-
256-
let token = res.body.token;
257-
258-
chai.request(app)
259-
.post('/badges/create')
260-
.set('Authorization', token)
261-
.send(badge_data_incorrect_issuer)
262-
.end((err, res) => {
263-
res.should.have.status(404);
264-
265-
done();
266-
});
267-
});
268-
}).timeout(100000);
269-
});
270-
271-
describe("GET /badges/badges/:address with a good address", () => {
272-
it("sign in and get badges by address", (done) => {
273-
chai.request(app)
274-
.post('/badges/users/signin')
275-
.send(login_details_correct)
276-
.end((err, res) => {
277-
res.should.have.status(201);
278-
res.body.should.be.a('object');
279-
res.body.should.have.property('token');
280-
281-
let token = res.body.token;
282-
283-
chai.request(app)
284-
.get('/badges/badges/'+badgeaddress)
285-
.set('Authorization', token)
286-
.end((err, res) => {
287-
res.should.have.status(200);
288-
289-
res.body.should.have.property('address');
290-
res.body.should.have.property('owner');
291-
res.body.should.have.property('title');
292-
res.body.should.have.property('description');
293-
res.body.should.have.property('imageurl');
294-
res.body.should.have.property('imagecaption');
295-
res.body.should.have.property('imageauthor');
296-
res.body.should.have.property('issuer');
297-
res.body.should.have.property('alignment');
298-
res.body.should.have.property('criteria');
299-
res.body.should.have.property('criteriaowner');
300-
res.body.should.have.property('criteriaid');
301-
res.body.should.have.property('criteriatype');
302-
res.body.should.have.property('criterianarrative');
303-
done();
304-
});
305-
});
306-
}).timeout(100000);
307-
});
308-
309-
describe("GET /badges/badges/:address with bad address", () => {
310-
it("sign in and return a 404", (done) => {
311-
chai.request(app)
312-
.post('/badges/users/signin')
313-
.send(login_details_correct)
314-
.end((err, res) => {
315-
res.should.have.status(201);
316-
res.body.should.be.a('object');
317-
res.body.should.have.property('token');
318-
319-
let token = res.body.token;
320-
321-
chai.request(app)
322-
.get('/badges/badges/'+badbadgeaddress)
323-
.set('Authorization', token)
324-
.end((err, res) => {
325-
res.should.have.status(404);
326-
done();
327-
});
328-
});
329-
}).timeout(100000);
330-
});
331-
332-
describe("GET /badges/badges/transaction/:address with a good address", () => {
333-
it("sign in and return transaction details", (done) => {
334-
chai.request(app)
335-
.post('/badges/users/signin')
336-
.send(login_details_correct)
337-
.end((err, res) => {
338-
res.should.have.status(201);
339-
res.body.should.be.a('object');
340-
res.body.should.have.property('token');
341-
342-
let token = res.body.token;
343-
344-
chai.request(app)
345-
.get('/badges/badges/transaction/'+badgeaddress)
346-
.set('Authorization', token)
347-
.end((err, res) => {
348-
res.should.have.status(200);
349-
res.body.should.have.property('transaction')
350-
351-
done();
352-
});
353-
});
354-
}).timeout(100000);
355-
});
356-
357-
describe("GET /badges/badges/transaction/:address with a bad address", () => {
358-
it("sign in and return a 404", (done) => {
359-
chai.request(app)
360-
.post('/badges/users/signin')
361-
.send(login_details_correct)
362-
.end((err, res) => {
363-
res.should.have.status(201);
364-
res.body.should.be.a('object');
365-
res.body.should.have.property('token');
366-
367-
let token = res.body.token;
368-
369-
chai.request(app)
370-
.get('/badges/badges/transaction/'+badbadgeaddress)
371-
.set('Authorization', token)
372-
.end((err, res) => {
373-
res.should.have.status(404);
374-
375-
done();
376-
});
377-
});
378-
}).timeout(100000);
379-
});
380-
381-
describe("POST /badges/badges/addalignment", () => {
382-
it("sign in and add an alignment to the badge", (done) => {
383-
chai.request(app)
384-
.post('/badges/users/signin')
385-
.send(login_details_correct)
386-
.end((err, res) => {
387-
res.should.have.status(201);
388-
res.body.should.be.a('object');
389-
res.body.should.have.property('token');
390-
391-
let token = res.body.token;
392-
393-
chai.request(app)
394-
.post('/badges/badges/addalignment')
395-
.set('Authorization', token)
396-
.send(badge_alignment_data)
397-
.end((err, res) => {
398-
res.should.have.status(200);
399-
res.body.should.have.property('transaction')
400-
401-
done();
402-
});
403-
});
404-
}).timeout(100000);
405-
});
406-
*/
407-
408-
/*
409-
describe("POST /badges/alignments/delete with good id", () => {
242+
describe("POST "+cfg.proxy_path+"/alignments/delete with good id", () => {
410243
it("should delete the alignment with the given id, only if not already used to issue a badge", (done) => {
411244
chai.request(app)
412-
.post('/badges/users/signin')
245+
.post(cfg.proxy_path+'/users/signin')
413246
.send(login_details_correct)
414247
.end((err, res) => {
415248
res.should.have.status(201);
@@ -419,7 +252,7 @@ describe("Alignments", () => {
419252
let token = res.body.token;
420253
421254
chai.request(app)
422-
.post('/badges/alignments/delete')
255+
.post(cfg.proxy_path+'/alignments/delete')
423256
.set('Authorization', token)
424257
.send(alignment_data_delete)
425258
.end((err, res) => {

0 commit comments

Comments
 (0)