Produced by Araxis Merge on 10/4/2017 8:04:33 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | rdk.zip\rdk\product\production\rdk\src\interceptors\authentication | authentication-spec.js | Mon Aug 21 12:51:00 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\interceptors\authentication | authentication-spec.js | Tue Oct 3 18:07:54 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 290 |
| Changed | 2 | 6 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | 'use stric t'; | |
| 2 | ||
| 3 | var _ = re quire('lod ash'); | |
| 4 | var bunyan = require ('bunyan') ; | |
| 5 | var httpMo cks = requ ire('node- mocks-http '); | |
| 6 | var auth = require(' ./authenti cation'); | |
| 7 | var rdk = require('. ./../core/ rdk'); | |
| 8 | var RdkErr or = rdk.u tils.RdkEr ror; | |
| 9 | ||
| 10 | var VALID_ ACCESS = ' R E DACT '; | |
| 11 | var VALID_ PASS = ' R E DACT '; | |
| 12 | var INVALI D_ACCESS = 'zzz'; | |
| 13 | var INVALI D_PASS = ' xxx'; | |
| 14 | var VALID_ SYSTEM = ' CDS'; | |
| 15 | var SITE = ' REDA C TED '; | |
| 16 | ||
| 17 | describe(' Authentica tion inter ceptor', f unction() { | |
| 18 | var re q; | |
| 19 | var re s; | |
| 20 | var ne xt; | |
| 21 | ||
| 22 | before Each(funct ion(done) { | |
| 23 | re q = httpMo cks.create Request({ | |
| 24 | method: 'GET', | |
| 25 | url: '/a uthenticat e' | |
| 26 | }) ; | |
| 27 | re q.logger = sinon.stu b(bunyan.c reateLogge r({ | |
| 28 | name: 'a uthenticat ion-interc eptor' | |
| 29 | }) ); | |
| 30 | ||
| 31 | _. set(req, ' _resourceC onfigItem. rel', 'vha .create'); | |
| 32 | ||
| 33 | _. set(req, ' app.config ', {}); | |
| 34 | _. set(req, ' app.config .intercept ors.authen tication.r eadOnly', true); | |
| 35 | _. set(req, ' app.config .intercept ors.authen tication.d isabled', false); | |
| 36 | ||
| 37 | _. set(req, ' session', { | |
| 38 | regenera te: sinon. stub().cal lsArg(0) | |
| 39 | }) ; | |
| 40 | ||
| 41 | ne xt = sinon .spy(); | |
| 42 | re s = httpMo cks.create Response() ; | |
| 43 | re s.rdkSend = sinon.sp y(); | |
| 44 | ||
| 45 | do ne(); | |
| 46 | }); | |
| 47 | ||
| 48 | afterE ach(functi on(done) { | |
| 49 | ne xt.reset() ; | |
| 50 | re q.logger.w arn.restor e(); | |
| 51 | re q.session. regenerate .reset(); | |
| 52 | re s.rdkSend. reset(); | |
| 53 | do ne(); | |
| 54 | }); | |
| 55 | ||
| 56 | it('te sts that e nabling th e intercep tor calls next after warning', function( ) { | |
| 57 | // purposly h it the dis abled inte rceptor | |
| 58 | _. set(req, ' _resourceC onfigItem. title', 'a uthenticat ion-authen tication') ; | |
| 59 | _. set(req, ' app.config .intercept ors.authen tication.d isabled', true); | |
| 60 | au th(req, re s, next); | |
| 61 | ex pect(req.l ogger.warn .called).t o.be.true( ); | |
| 62 | ex pect(res.r dkSend.cal led).to.be .false(); | |
| 63 | ex pect(next. called).to .be.true() ; | |
| 64 | }); | |
| 65 | ||
| 66 | it('te sts that e nabling th e intercep tor calls next with no warning or rdkSen d', functi on() { | |
| 67 | // bypass eve rything | |
| 68 | _. set(req, ' session.us er.consume rType', 'u ser'); | |
| 69 | _. set(req, ' _resourceC onfigItem. title', 'a uthenticat ion-refres hToken'); | |
| 70 | au th(req, re s, next); | |
| 71 | ex pect(req.l ogger.warn .called).t o.be.false (); | |
| 72 | ex pect(res.r dkSend.cal led).to.be .false(); | |
| 73 | ex pect(next. called).to .be.true() ; | |
| 74 | }); | |
| 75 | ||
| 76 | it('te sts that a n invalid user can\' t call res ources oth er than au thenticati on resourc es', funct ion() { | |
| 77 | _. set(req, ' _resourceC onfigItem. title', 'p ostulate-t his-fresh- beat'); | |
| 78 | au th(req, re s, next); | |
| 79 | ex pect(req.l ogger.warn .called).t o.be.false (); | |
| 80 | ex pect(res.r dkSend.cal led).to.be .true(); | |
| 81 | ex pect(res.r dkSend.cal ledWithMat ch(new Rdk Error({ | |
| 82 | code: 'r dk.401.100 2', | |
| 83 | logger: req.logger | |
| 84 | }) )).to.be.t rue(); | |
| 85 | ex pect(next. called).to .be.false( ); | |
| 86 | }); | |
| 87 | ||
| 88 | it('te sts that n ext is cal led when a n invalid user is ca lling an a uthenticat ion resour ce so that login may occur', f unction() { | |
| 89 | _. set(req, ' body', { | |
| 90 | accessCo de: INVALI D_ACCESS, | |
| 91 | verifyCo de: INVALI D_PASS, | |
| 92 | site: SI TE | |
| 93 | }) ; | |
| 94 | _. set(req, ' _resourceC onfigItem. title', 'a uthenticat ion-authen tication') ; | |
| 95 | au th(req, re s, next); | |
| 96 | ex pect(req.l ogger.warn .called).t o.be.false (); | |
| 97 | ex pect(res.r dkSend.cal led).to.be .false(); | |
| 98 | ex pect(req.s ession.reg enerate.ca lled).to.b e.true(); | |
| 99 | ex pect(next. called).to .be.true() ; | |
| 100 | }); | |
| 101 | ||
| 102 | it('te sts that n ext is cal led when a n invalid system use r is calli ng an auth entication resource so that lo gin may oc cur', func tion() { | |
| 103 | _. set(req, ' headers', { | |
| 104 | authoriz ation: VAL ID_SYSTEM | |
| 105 | }) ; | |
| 106 | _. set(req, ' _resourceC onfigItem. title', 'a uthenticat ion-intern al-systems -authentic ate'); | |
| 107 | au th(req, re s, next); | |
| 108 | ex pect(req.l ogger.warn .called).t o.be.false (); | |
| 109 | ex pect(res.r dkSend.cal led).to.be .false(); | |
| 110 | ex pect(req.s ession.reg enerate.ca lled).to.b e.true(); | |
| 111 | ex pect(next. called).to .be.true() ; | |
| 112 | }); | |
| 113 | ||
| 114 | it('te sts that c alling a l ogin resou rce with a valid ses sion and u ser creden tials will not regen erate the session an d calls ne xt', funct ion() { | |
| 115 | _. set(req, ' body', { | |
| 116 | accessCo de: VALID_ ACCESS, | |
| 117 | verifyCo de: VALID_ PASS, | |
| 118 | site: SI TE | |
| 119 | }) ; | |
| 120 | _. set(req, ' session.us er', { | |
| 121 | accessCo de: VALID_ ACCESS, | |
| 122 | password : VALID_PA SS, | |
| 123 | site: SI TE, | |
| 124 | consumer Type: 'use r' | |
| 125 | }) ; | |
| 126 | _. set(req, ' _resourceC onfigItem. title', 'a uthenticat ion-authen tication') ; | |
| 127 | au th(req, re s, next); | |
| 128 | ex pect(req.l ogger.warn .called).t o.be.false (); | |
| 129 | ex pect(res.r dkSend.cal led).to.be .false(); | |
| 130 | ex pect(req.s ession.reg enerate.ca lled).to.b e.false(); | |
| 131 | ex pect(next. called).to .be.true() ; | |
| 132 | }); | |
| 133 | it('te sts that c alling a l ogin resou rce with a valid ses sion and s ystem user credentia ls will no t regenera te the ses sion and c alls next' , function () { | |
| 134 | _. set(req, ' headers', { | |
| 135 | authoriz ation: VAL ID_SYSTEM | |
| 136 | }) ; | |
| 137 | _. set(req, ' session.us er', { | |
| 138 | name: VA LID_SYSTEM , | |
| 139 | consumer Type: 'sys tem' | |
| 140 | }) ; | |
| 141 | _. set(req, ' _resourceC onfigItem. title', 'a uthenticat ion-intern al-systems -authentic ate'); | |
| 142 | au th(req, re s, next); | |
| 143 | ex pect(req.l ogger.warn .called).t o.be.false (); | |
| 144 | ex pect(res.r dkSend.cal led).to.be .false(); | |
| 145 | ex pect(req.s ession.reg enerate.ca lled).to.b e.false(); | |
| 146 | ex pect(next. called).to .be.true() ; | |
| 147 | }); | |
| 148 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.