Produced by Araxis Merge on 10/4/2017 8:04:35 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\subsystems\authentication\modules | pjds-user-data-spec.js | Mon Aug 28 19:41:48 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\subsystems\authentication\modules | pjds-user-data-spec.js | Tue Oct 3 18:29:53 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 24 | 664 |
| Changed | 23 | 56 |
| 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 | var _ = re quire('lod ash'); | |
| 3 | var nock = require(' nock'); | |
| 4 | var httpMo cks = requ ire('node- mocks-http '); | |
| 5 | var logger = sinon.s tub(requir e('bunyan' ).createLo gger({ | |
| 6 | name: 'pjds-user -data-spec ' | |
| 7 | })); | |
| 8 | var pjdsUs erData = r equire('./ pjds-user- data'); | |
| 9 | ||
| 10 | var trustU ser = { | |
| 11 | uid: ' CDS', | |
| 12 | name: 'CDS', | |
| 13 | permis sionSet: { | |
| 14 | ad ditionalPe rmissions: ['add-fri dge-sticke r'], | |
| 15 | va l: ['read- access'] | |
| 16 | }, | |
| 17 | status : 'active' , | |
| 18 | system Designator : 'externa l' | |
| 19 | }; | |
| 20 | var fakeUs er = { | |
| 21 | uid: ' FAKER', | |
| 22 | name: 'FAKER', | |
| 23 | permis sionSet: { | |
| 24 | va l: ['read- access'], | |
| 25 | ad ditionalPe rmissions: ['knifes- edge'] | |
| 26 | }, | |
| 27 | breakg lass: true | |
| 28 | }; | |
| 29 | var subjec tUser = { | |
| 30 | uid: 'urn: va:user: REDACTED :0007', | |
| 31 | permis sionSet: { | |
| 32 | ad ditionalPe rmissions: [ | |
| 33 | 'judo-ch op', | |
| 34 | 'can-yod el' | |
| 35 | ], | |
| 36 | modifiedBy : 'urn:va: user: REDACTED :0001', | |
| 37 | mo difiedOn: '2017-03-1 4T13:59:26 Z', | |
| 38 | va l: [ | |
| 39 | 'read-ac cess', | |
| 40 | 'sumo-wr estler', | |
| 41 | 'potty-t rained' | |
| 42 | ] | |
| 43 | }, | |
| 44 | status : 'active' | |
| 45 | }; | |
| 46 | var permis sionSets = { | |
| 47 | items: [{ | |
| 48 | 'u id': 'sumo -wrestler' , | |
| 49 | 'l abel': 'Su mo Wrestle r', | |
| 50 | 'p ermissions ': ['not-t o-be-trifl ed-with'], | |
| 51 | 's tatus': 'a ctive' | |
| 52 | }, { | |
| 53 | 'u id': 'read -access', | |
| 54 | 'l abel': 'Re ad Access' , | |
| 55 | 'p ermissions ': ['i-can -has-read' ], | |
| 56 | 's tatus': 'a ctive' | |
| 57 | }] | |
| 58 | }; | |
| 59 | var permis sions = { | |
| 60 | items: [{ | |
| 61 | 'u id': 'not- to-be-trif led-with', | |
| 62 | 'l abel': 'Se riously, d on\'t trif le', | |
| 63 | 's tatus': 'a ctive' | |
| 64 | }, { | |
| 65 | 'u id': 'i-ca n-has-read ', | |
| 66 | 'l abel': 'Pa ssed 1st g rade after 3rd try', | |
| 67 | 's tatus': 'a ctive' | |
| 68 | }, { | |
| 69 | 'u id': 'add- fridge-sti cker', | |
| 70 | 'l abel': 'Ce lebrate Po tty Time w ith Sticke rs!', | |
| 71 | 's tatus': 'a ctive' | |
| 72 | }, { | |
| 73 | 'u id': 'judo -chop', | |
| 74 | 'l abel': 'Ju do CHOP', | |
| 75 | 'd escription ': 'Downwa rd chop to the upwar d facing a ir', | |
| 76 | 's tatus': 'a ctive' | |
| 77 | }] | |
| 78 | }; | |
| 79 | var appCon fig = { | |
| 80 | 'gener alPurposeJ dsServer': { | |
| 81 | 'baseUrl': 'http:// IP ', | |
| 82 | 'u rlLengthLi mit': 120 | |
| 83 | } | |
| 84 | }; | |
| 85 | ||
| 86 | describe(' pJDS eHMP User Data module', f unction() { | |
| 87 | var re q; | |
| 88 | var re s; | |
| 89 | ||
| 90 | before Each(funct ion(done) { | |
| 91 | re q = httpMo cks.create Request({ | |
| 92 | method: 'GET', | |
| 93 | url: '/e hmpusers/{ uid}' | |
| 94 | }) ; | |
| 95 | re q.logger = logger; | |
| 96 | _. set(req, ' app.config ', appConf ig); | |
| 97 | ||
| 98 | re s = httpMo cks.create Response() ; | |
| 99 | ||
| 100 | nock('http :// IP ') | |
| 101 | .get('/p ermset/?fi lter=eq(%2 2status%22 %2C%22acti ve%22)') | |
| 102 | .reply(2 00, permis sionSets); | |
| 103 | nock('http :// IP ') | |
| 104 | .get('/p ermission/ ?filter=eq (%22status %22%2C%22a ctive%22)' ) | |
| 105 | .reply(2 00, permis sions); | |
| 106 | do ne(); | |
| 107 | }); | |
| 108 | ||
| 109 | afterE ach(functi on(done) { | |
| 110 | no ck.cleanAl l(); | |
| 111 | do ne(); | |
| 112 | }); | |
| 113 | ||
| 114 | it('ma kes the ca llback ear ly with an error and no data i f the uid is blank', function( done) { | |
| 115 | va r data = { | |
| 116 | duz: {} | |
| 117 | }; | |
| 118 | va r params = { | |
| 119 | site: ' R E D A CTED ', | |
| 120 | data: da ta | |
| 121 | }; | |
| 122 | ||
| 123 | va r cb = fun ction(err, data) { | |
| 124 | expect(e rr.code, ' The error code shoul d match th e given er ror').to.m atch(/202. 412.1001/) ; | |
| 125 | expect(d ata, 'No d ata should be send o n the call back with error').to .be.null() ; | |
| 126 | done(); | |
| 127 | }; | |
| 128 | ||
| 129 | pj dsUserData .getEhmpUs erData(req , res, cb, params); | |
| 130 | }); | |
| 131 | ||
| 132 | it('ma kes the ca llback wit h error wh en pjds re turns an e rror', fun ction(done ) { | |
| 133 | va r data = { | |
| 134 | uid: 'urn: va:user: REDACTED :0007' | |
| 135 | }; | |
| 136 | va r params = { | |
| 137 | site: ' REDACTED ', | |
| 138 | data: da ta | |
| 139 | }; | |
| 140 | ||
| 141 | va r cb = fun ction (err , data) { | |
| 142 | expect(e rr.code, ' The error code shoul d match th e given er ror').to.m atch(/202. 500.1001/) ; | |
| 143 | expect(d ata, 'No d ata should be send o n the call back with error').to .be.null() ; | |
| 144 | done(); | |
| 145 | }; | |
| 146 | ||
| 147 | nock('http :// IP ') | |
| 148 | .get('/ehm pusers/urn :va:user: REDACTED :0007') | |
| 149 | .reply(4 04, new Er ror('Addre ss Unknown ')); | |
| 150 | ||
| 151 | pj dsUserData .getEhmpUs erData(req , res, cb, params); | |
| 152 | }); | |
| 153 | ||
| 154 | it('ma kes the ca llback whe n pJDS ret urns data as expecte d', functi on(done) { | |
| 155 | va r data = { | |
| 156 | uid: 'urn: va:user: REDACTED :0007' | |
| 157 | }; | |
| 158 | va r params = { | |
| 159 | site: ' REDACTED ', | |
| 160 | data: da ta | |
| 161 | }; | |
| 162 | ||
| 163 | va r cb = fun ction (err , data) { | |
| 164 | expect(e rr, 'The e rror shoul d be null' ).to.be.nu ll(); | |
| 165 | expect(d ata, 'The response s hould have the follo wing keys' ).to.be.ha ve.keys([' eHMPUICont ext', 'pre ferences', 'permissi ons', 'per missionSet s', 'uid', 'unsucces sfulLoginA ttemptCoun t']); | |
| 166 | expect(_ .get(data, 'unsucces sfulLoginA ttemptCoun t'), 'The login coun t should b e reset to 0').to.be (0); | |
| 167 | expect(_ .get(data, 'permissi onSets'), 'The respo nse should contain t he followi ng permiss ion sets') .to.be.a.p ermutation Of(['read- access', ' sumo-wrest ler']); | |
| 168 | done(); | |
| 169 | }; | |
| 170 | ||
| 171 | nock('http :// IP ') | |
| 172 | .get('/ehm pusers/urn :va:user: REDACTED :0007') | |
| 173 | .reply(2 00, subjec tUser); | |
| 174 | ||
| 175 | pj dsUserData .getEhmpUs erData(req , res, cb, params); | |
| 176 | }); | |
| 177 | }); | |
| 178 | ||
| 179 | describe(' pJDS trust system da ta call', function() { | |
| 180 | var re q; | |
| 181 | var re s; | |
| 182 | ||
| 183 | before Each(funct ion(done) { | |
| 184 | re q = httpMo cks.create Request({ | |
| 185 | method: 'GET', | |
| 186 | url: '/t rustsys/{u id}' | |
| 187 | }) ; | |
| 188 | re q.logger = logger; | |
| 189 | _. set(req, ' app.config ', appConf ig); | |
| 190 | ||
| 191 | nock('http :// IP ') | |
| 192 | .get('/p ermset/?fi lter=ilike (%22status %22%2C%22a ctive%25%2 2)') | |
| 193 | .reply(2 00, permis sionSets); | |
| 194 | nock('http :// IP ') | |
| 195 | .get('/p ermission/ ?filter=il ike(%22sta tus%22%2C% 22active%2 5%22)') | |
| 196 | .reply(2 00, permis sions); | |
| 197 | ||
| 198 | re s = httpMo cks.create Response() ; | |
| 199 | ||
| 200 | do ne(); | |
| 201 | }); | |
| 202 | ||
| 203 | afterE ach(functi on(done) { | |
| 204 | no ck.cleanAl l(); | |
| 205 | do ne(); | |
| 206 | }); | |
| 207 | ||
| 208 | it('ma kes the ca llback ear ly with an error and no data i f the name is blank' , function (done) { | |
| 209 | va r params = {}; | |
| 210 | va r cb = fun ction (err , data) { | |
| 211 | expect(e rr.code, ' The error code shoul d match th e given er ror').to.m atch(/202. 412.1001/) ; | |
| 212 | expect(d ata, 'No d ata should be send o n the call back with error').to .be.null() ; | |
| 213 | done(); | |
| 214 | }; | |
| 215 | ||
| 216 | pj dsUserData .getTruste dSystemDat a(req, res , cb, para ms); | |
| 217 | }); | |
| 218 | ||
| 219 | it('ma kes the ca llback wit h error wh en pjds re turns an e rror', fun ction(done ) { | |
| 220 | va r params = { | |
| 221 | name: 'N BC' | |
| 222 | }; | |
| 223 | ||
| 224 | va r cb = fun ction (err , data) { | |
| 225 | expect(e rr.code, ' The error code shoul d match th e given er ror').to.m atch(/202. 401.1003/) ; | |
| 226 | expect(d ata, 'No d ata should be send o n the call back with error').to .be.null() ; | |
| 227 | done(); | |
| 228 | }; | |
| 229 | ||
| 230 | nock('http :// IP ') | |
| 231 | .get('/t rustsys/NB C') | |
| 232 | .reply(4 04, new Er ror('Nope. Not gonna do it!')) ; | |
| 233 | ||
| 234 | pj dsUserData .getTruste dSystemDat a(req, res , cb, para ms); | |
| 235 | }); | |
| 236 | ||
| 237 | it('ma kes the ca llback wit h no data when pjds returns no error and a name th at doesn\' t match th e requeste d name', f unction(do ne) { | |
| 238 | va r params = { | |
| 239 | name: 'C DS' | |
| 240 | }; | |
| 241 | va r cb = fun ction (err , data) { | |
| 242 | expect(e rr.error). to.match(/ response n ame did no t match th e request name/); | |
| 243 | expect(d ata, 'No d ata should be send o n the call back with error').to .be.null() ; | |
| 244 | done(); | |
| 245 | }; | |
| 246 | ||
| 247 | nock('http :// IP ') | |
| 248 | .get('/t rustsys/CD S') | |
| 249 | .reply(2 00, fakeUs er); | |
| 250 | ||
| 251 | pj dsUserData .getTruste dSystemDat a(req, res , cb, para ms); | |
| 252 | }); | |
| 253 | ||
| 254 | it('ma kes the ca llback wit h data whe n pjds ret urns no er ror', func tion(done) { | |
| 255 | va r params = { | |
| 256 | name: 'C DS' | |
| 257 | }; | |
| 258 | va r cb = fun ction (err , data) { | |
| 259 | expect(e rr, 'The e rror shoul d be null' ).to.be.nu ll(); | |
| 260 | expect(_ .keys(data ), 'Respon se should have keys' ).to.be.pe rmutationO f(['uid',' name','per missionSet ','status' ,'systemDe signator', 'createdBy ','created Time','las tSuccessfu lLogin','l astUnsucce ssfulLogin ','unsucce ssfulLogin AttemptCou nt','permi ssions','b reakglass' ,'consumer Type','per missionSet s']); | |
| 261 | done(); | |
| 262 | }; | |
| 263 | ||
| 264 | nock('http :// IP ') | |
| 265 | .get('/t rustsys/CD S') | |
| 266 | .reply(2 00, trustU ser); | |
| 267 | ||
| 268 | pj dsUserData .getTruste dSystemDat a(req, res , cb, para ms); | |
| 269 | }); | |
| 270 | }); | |
| 271 | ||
| 272 | describe(' pJDS store login att empt call' , function () { | |
| 273 | var re q; | |
| 274 | var re s; | |
| 275 | ||
| 276 | before Each(funct ion(done) { | |
| 277 | re q = httpMo cks.create Request({ | |
| 278 | method: 'GET', | |
| 279 | url: '/e hmpusers/{ uid}' | |
| 280 | }) ; | |
| 281 | re q.logger = logger; | |
| 282 | _. set(req, ' app.config ', appConf ig); | |
| 283 | ||
| 284 | re s = httpMo cks.create Response() ; | |
| 285 | ||
| 286 | do ne(); | |
| 287 | }); | |
| 288 | ||
| 289 | afterE ach(functi on(done) { | |
| 290 | no ck.cleanAl l(); | |
| 291 | do ne(); | |
| 292 | }); | |
| 293 | ||
| 294 | it('ma kes the ca llback ear ly with da ta if the uid is bla nk', funct ion(done) { | |
| 295 | va r params = { | |
| 296 | data: {} | |
| 297 | }; | |
| 298 | va r cb =func tion (err, data) { | |
| 299 | expect(e rr.code, ' The error code shoul d match th e given er ror').to.b e.match(/2 02.412.100 1/); | |
| 300 | expect(d ata, 'No d ata should be send o n the call back with error').to .be.null() ; | |
| 301 | done(); | |
| 302 | }; | |
| 303 | ||
| 304 | pj dsUserData .setLoginA ttempt(req , res, cb, params); | |
| 305 | }); | |
| 306 | ||
| 307 | it('ma kes the ca llback wit h error wh en pjds re turns an e rror', fun ction(done ) { | |
| 308 | va r cb = fun ction (err , data) { | |
| 309 | expect(e rr.code, ' The error code shoul d match th e given er ror').to.m atch(/202. 500.1001/) ; | |
| 310 | expect(d ata, 'No d ata should be send o n the call back with error').to .be.null() ; | |
| 311 | done(); | |
| 312 | }; | |
| 313 | va r params = {}; | |
| 314 | _. set(params , 'data', {}); | |
| 315 | _.set(req, 'session. user.uid', 'urn:va:u ser: REDACTED :0007'); | |
| 316 | ||
| 317 | nock('http :// IP ') | |
| 318 | .patch('/e hmpusers/u rn:va:user : REDACTED :0007') | |
| 319 | .reply(4 04, new Er ror('This is bogus') ); | |
| 320 | ||
| 321 | pj dsUserData .setLoginA ttempt(req , res, cb, params); | |
| 322 | }); | |
| 323 | ||
| 324 | it('se ts default data prop erly for p jds patch if error d uring logi n', functi on(done) { | |
| 325 | va r message = 'login w asn\'t suc cessful'; | |
| 326 | va r cb = fun ction (err , data) { | |
| 327 | expect(e rr, 'The e rror messa ge should match the given mess age').to.m atch(messa ge); | |
| 328 | expect(d ata, 'No d ata should be send o n the call back with error').to .be.null() ; | |
| 329 | done(); | |
| 330 | }; | |
| 331 | va r params = {}; | |
| 332 | _. set(params , 'data', {}); | |
| 333 | _. set(params , 'error', new Error (message)) ; | |
| 334 | _.set(req, 'session. user.uid', 'urn:va:u ser: REDACTED :0007'); | |
| 335 | ||
| 336 | nock('http :// IP ') | |
| 337 | .patch('/e hmpusers/u rn:va:user : REDACTED :0007') | |
| 338 | .reply(2 00, subjec tUser); | |
| 339 | ||
| 340 | pj dsUserData .setLoginA ttempt(req , res, cb, params); | |
| 341 | }); | |
| 342 | ||
| 343 | it('ma kes the ca llback wit h data whe n pjds ret urns no er ror', func tion(done) { | |
| 344 | va r cb = fun ction (err , data) { | |
| 345 | expect(e rr, 'The e rror shoul d be null' ).to.be.nu ll(); | |
| 346 | expect(d ata).to.ha ve.keys([' permission s', 'permi ssionSets' ]); | |
| 347 | done(); | |
| 348 | }; | |
| 349 | va r params = {}; | |
| 350 | _. set(params , 'data.pe rmissionSe ts', ['sum o-wrestler ']); | |
| 351 | _. set(params , 'data.pe rmissions' , ['judo-c hop']); | |
| 352 | _.set(req, 'session. user.uid', 'urn:va:u ser: REDACTED :0007'); | |
| 353 | ||
| 354 | nock('http :// IP ') | |
| 355 | .patch('/e hmpusers/u rn:va:user : REDACTED :0007') | |
| 356 | .reply(2 00, subjec tUser); | |
| 357 | ||
| 358 | pj dsUserData .setLoginA ttempt(req , res, cb, params); | |
| 359 | }); | |
| 360 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.