aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/checkParams.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-05 17:19:08 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-05 17:19:08 +0200
commit99a64bfed25e45547df3045cf249bc895e6f220b (patch)
tree0e8150155d616ee25eac41196bdb6cf7413b376c /server/tests/api/checkParams.js
parent6606150c49f587bc7eb0ecec4263ce7fbb18bf15 (diff)
downloadPeerTube-99a64bfed25e45547df3045cf249bc895e6f220b.tar.gz
PeerTube-99a64bfed25e45547df3045cf249bc895e6f220b.tar.zst
PeerTube-99a64bfed25e45547df3045cf249bc895e6f220b.zip
Server: allow user to get its informations (/users/me)
Diffstat (limited to 'server/tests/api/checkParams.js')
-rw-r--r--server/tests/api/checkParams.js34
1 files changed, 27 insertions, 7 deletions
diff --git a/server/tests/api/checkParams.js b/server/tests/api/checkParams.js
index bd7227e9c..8b49f5f36 100644
--- a/server/tests/api/checkParams.js
+++ b/server/tests/api/checkParams.js
@@ -504,6 +504,8 @@ describe('Test parameters validator', function () {
504 504
505 describe('Of the users API', function () { 505 describe('Of the users API', function () {
506 const path = '/api/v1/users/' 506 const path = '/api/v1/users/'
507 let userId = null
508 let userAccessToken = null
507 509
508 describe('When adding a new user', function () { 510 describe('When adding a new user', function () {
509 it('Should fail with a too small username', function (done) { 511 it('Should fail with a too small username', function (done) {
@@ -580,19 +582,19 @@ describe('Test parameters validator', function () {
580 utils.loginAndGetAccessToken(server, function (err, accessToken) { 582 utils.loginAndGetAccessToken(server, function (err, accessToken) {
581 if (err) throw err 583 if (err) throw err
582 584
585 userAccessToken = accessToken
586
583 const data = { 587 const data = {
584 username: 'user2', 588 username: 'user2',
585 password: 'my super password' 589 password: 'my super password'
586 } 590 }
587 591
588 makePostBodyRequest(path, accessToken, data, done, 403) 592 makePostBodyRequest(path, userAccessToken, data, done, 403)
589 }) 593 })
590 }) 594 })
591 }) 595 })
592 596
593 describe('When updating a user', function () { 597 describe('When updating a user', function () {
594 let userId = null
595
596 before(function (done) { 598 before(function (done) {
597 utils.getUsersList(server.url, function (err, res) { 599 utils.getUsersList(server.url, function (err, res) {
598 if (err) throw err 600 if (err) throw err
@@ -607,7 +609,7 @@ describe('Test parameters validator', function () {
607 password: 'bla' 609 password: 'bla'
608 } 610 }
609 611
610 makePutBodyRequest(path + '/' + userId, server.accessToken, data, done) 612 makePutBodyRequest(path + userId, userAccessToken, data, done)
611 }) 613 })
612 614
613 it('Should fail with a too long password', function (done) { 615 it('Should fail with a too long password', function (done) {
@@ -617,7 +619,7 @@ describe('Test parameters validator', function () {
617 'very very very very very very very very very very very very very very very very very very very very long' 619 'very very very very very very very very very very very very very very very very very very very very long'
618 } 620 }
619 621
620 makePutBodyRequest(path + '/' + userId, server.accessToken, data, done) 622 makePutBodyRequest(path + userId, userAccessToken, data, done)
621 }) 623 })
622 624
623 it('Should fail with an non authenticated user', function (done) { 625 it('Should fail with an non authenticated user', function (done) {
@@ -625,7 +627,7 @@ describe('Test parameters validator', function () {
625 password: 'my super password' 627 password: 'my super password'
626 } 628 }
627 629
628 makePutBodyRequest(path + '/' + userId, 'super token', data, done, 401) 630 makePutBodyRequest(path + userId, 'super token', data, done, 401)
629 }) 631 })
630 632
631 it('Should succeed with the correct params', function (done) { 633 it('Should succeed with the correct params', function (done) {
@@ -633,7 +635,25 @@ describe('Test parameters validator', function () {
633 password: 'my super password' 635 password: 'my super password'
634 } 636 }
635 637
636 makePutBodyRequest(path + '/' + userId, server.accessToken, data, done, 204) 638 makePutBodyRequest(path + userId, userAccessToken, data, done, 204)
639 })
640 })
641
642 describe('When getting my information', function () {
643 it('Should fail with a non authenticated user', function (done) {
644 request(server.url)
645 .get(path + 'me')
646 .set('Authorization', 'Bearer faketoken')
647 .set('Accept', 'application/json')
648 .expect(401, done)
649 })
650
651 it('Should success with the correct parameters', function (done) {
652 request(server.url)
653 .get(path + 'me')
654 .set('Authorization', 'Bearer ' + userAccessToken)
655 .set('Accept', 'application/json')
656 .expect(200, done)
637 }) 657 })
638 }) 658 })
639 659