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\resources\permission-sets | multi-user-edit-spec.js | Mon Aug 28 19:41:48 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\resources\permission-sets | multi-user-edit-spec.js | Tue Oct 3 18:22:40 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 20 | 426 |
| Changed | 19 | 62 |
| 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 nock = require(' nock'); | |
| 5 | var httpMo cks = requ ire('node- mocks-http '); | |
| 6 | var multiU serEdit = require('. /multi-use r-edit'); | |
| 7 | var testDa ta = requi re('./perm ission-set s-test-dat a.json'); | |
| 8 | var logger = sinon.s tub(requir e('bunyan' ).createLo gger({ | |
| 9 | name: 'multi-use r-edit' | |
| 10 | })); | |
| 11 | var rdk = require('. ./../core/ rdk'); | |
| 12 | var pjds = rdk.utils .pjdsStore ; | |
| 13 | ||
| 14 | describe(' Multi User Edit', fu nction() { | |
| 15 | var re q; | |
| 16 | var re s; | |
| 17 | ||
| 18 | before Each(funct ion(done) { | |
| 19 | re q = httpMo cks.create Request({ | |
| 20 | method: 'PUT', | |
| 21 | url: 're source/per mission-se ts/edit' | |
| 22 | }) ; | |
| 23 | _. set(req, ' app.config .generalPu rposeJdsSe rver', { | |
| 24 | baseUrl: ' http:// IP ', | |
| 25 | urlLengt hLimit: 12 0 | |
| 26 | }) ; | |
| 27 | _. set(req, ' app.config .jbpm.ehmp routingDat abase', { | |
| 28 | user: 'n one', | |
| 29 | password : 'fake', | |
| 30 | connectStr ing: ' IP /XE' | |
| 31 | }) ; | |
| 32 | _. set(req, ' audit', {} ); | |
| 33 | _. set(req, ' logger', l ogger); | |
| 34 | _. set(req, ' session.us er', _.clo ne(testDat a.actingUs er)); | |
| 35 | _. set(req, ' session.us er.consume rType', 'u ser'); | |
| 36 | re s = httpMo cks.create Response() ; | |
| 37 | re s.rdkSend = function (result) {}; | |
| 38 | do ne(); | |
| 39 | }); | |
| 40 | ||
| 41 | afterE ach(functi on(done) { | |
| 42 | no ck.cleanAl l(); | |
| 43 | do ne(); | |
| 44 | }); | |
| 45 | ||
| 46 | descri be('stops early when ', functio n() { | |
| 47 | be foreEach(f unction() { | |
| 48 | _.set(re q, ['sessi on', 'user ', 'permis sionSet', 'val', 0], 'acc'); | |
| 49 | }) ; | |
| 50 | ||
| 51 | it ('no user is sent', function() { | |
| 52 | _.set(re q, 'query. permission Sets', ['n one']); | |
| 53 | _.set(re q, 'query. mode', 'ad d'); | |
| 54 | res.rdkS end = func tion(respo nse) { | |
| 55 | expe ct(respons e).to.matc h(/Missing users par ameter/); | |
| 56 | }; | |
| 57 | multiUse rEdit(req, res); | |
| 58 | }) ; | |
| 59 | ||
| 60 | it ('no permi ssionSets is sent', function() { | |
| 61 | _.set(re q, 'query. users', [{ 'uid':'bog us'}]); | |
| 62 | _.set(re q, 'query. mode', 'ad d'); | |
| 63 | res.rdkS end = func tion(respo nse) { | |
| 64 | expe ct(respons e.code).to .equal('20 0.400.1020 '); | |
| 65 | }; | |
| 66 | multiUse rEdit(req, res); | |
| 67 | }) ; | |
| 68 | ||
| 69 | it ('no mode is sent', function() { | |
| 70 | _.set(re q, 'query. permission Sets', ['n one']); | |
| 71 | _.set(re q, 'query. users', [{ 'uid':'bog us'}]); | |
| 72 | res.rdkS end = func tion(respo nse) { | |
| 73 | expe ct(respons e.code).to .equal('20 0.400.1022 '); | |
| 74 | }; | |
| 75 | multiUse rEdit(req, res); | |
| 76 | }) ; | |
| 77 | ||
| 78 | it ('no valid mode is s ent', func tion() { | |
| 79 | _.set(re q, 'query. permission Sets', ['n one']); | |
| 80 | _.set(re q, 'query. users', [{ 'uid':'bog us'}]); | |
| 81 | _.set(re q, 'query. mode', 'wr ong'); | |
| 82 | res.rdkS end = func tion(respo nse) { | |
| 83 | expe ct(respons e.code).to .equal('20 0.400.1023 '); | |
| 84 | }; | |
| 85 | multiUse rEdit(req, res); | |
| 86 | }) ; | |
| 87 | }); | |
| 88 | ||
| 89 | descri be('having \'acc\' p ermission set', func tion() { | |
| 90 | be foreEach(f unction() { | |
| 91 | _.set(re q, ['sessi on', 'user ', 'permis sionSet', 'val', 0], 'acc'); | |
| 92 | _.set(re q, ['sessi on', 'user ', 'permis sions'], [ | |
| 93 | 'add -user-perm ission-set ', | |
| 94 | 'edi t-user-per mission-se t', | |
| 95 | 'rea d-user-per mission-se t', | |
| 96 | 'rem ove-user-p ermission- set' | |
| 97 | ]); | |
| 98 | _.set(re q, 'query' , { | |
| 99 | user s: [], | |
| 100 | mode : 'add', | |
| 101 | perm issionSets : ['contes tant-at-ea ting'], | |
| 102 | addi tionalPerm issions: [ 'pie-is-gr eat'] | |
| 103 | }); | |
| 104 | }) ; | |
| 105 | ||
| 106 | it ('does not allow a u ser to edi t their ow n permissi ons withou t \'edit-o wn-permiss ions\'', f unction() { | |
| 107 | _.set(re q, ['query ', 'users' , 0, 'uid' ], testDat a.actingUs er.uid); | |
| 108 | ||
| 109 | nock('http :// IP ') | |
| 110 | .get ('/permset /?filter=e q(%22statu s%22%2C%22 active%22) ') | |
| 111 | .rep ly(200, _. clone(test Data.permi ssionSet)) ; | |
| 112 | ||
| 113 | nock('http :// IP ') | |
| 114 | .get('/ehm pusers/urn :va:user: REDACTED :0007') | |
| 115 | .rep ly(200, _. clone(test Data.actin gUser)); | |
| 116 | ||
| 117 | res.rdkS end = func tion(respo nse) { | |
| 118 | expe ct(_.get(r esponse, [ 'data', 'f ailedOnEdi tUsers', 0 , 'errorMe ssage'])). to.match(/ Not allowe d to edit your own p ermissions /); | |
| 119 | }; | |
| 120 | multiUse rEdit(req, res); | |
| 121 | }) ; | |
| 122 | ||
| 123 | it ('does all ow a user to edit th eir own pe rmissions with \'edi t-own-perm issions\'' , function (done) { | |
| 124 | _.set(re q, ['query ', 'users' , 0, 'uid' ], testDat a.actingUs er.uid); | |
| 125 | _.set(re q, ['sessi on', 'user ', 'permis sionSet', 'additiona lPermissio ns', 0], ' edit-own-p ermissions '); | |
| 126 | req.sess ion.user.p ermissions .push('edi t-own-perm issions'); | |
| 127 | ||
| 128 | nock('http :// IP ') | |
| 129 | .get ('/permset /?filter=e q(%22statu s%22%2C%22 active%22) ') | |
| 130 | .rep ly(200, _. clone(test Data.permi ssionSet)) ; | |
| 131 | ||
| 132 | nock('http :// IP ') | |
| 133 | .get('/ehm pusers/urn :va:user: REDACTED :0007') | |
| 134 | .rep ly(200, _. clone(test Data.actin gUser)); | |
| 135 | ||
| 136 | nock('http :// IP ') | |
| 137 | .put('/ehm pusers/urn :va:user: REDACTED :0007') | |
| 138 | .rep ly(201, {} ); | |
| 139 | ||
| 140 | res.rdkS end = func tion(respo nse) { | |
| 141 | expe ct(_.get(r esponse, [ 'data', 'e ditedUsers ', 0])).to .have.ownP roperty('u id', testD ata.acting User.uid); | |
| 142 | done (); | |
| 143 | }; | |
| 144 | ||
| 145 | multiUse rEdit(req, res); | |
| 146 | }) ; | |
| 147 | ||
| 148 | it ('does all ow a user to edit an other user \'s permis sions', fu nction(don e) { | |
| 149 | _.set(re q, ['query ', 'users' ], testDat a.users); | |
| 150 | req.sess ion.user.p ermissions .push('edi t-own-perm issions'); | |
| 151 | ||
| 152 | nock('http :// IP ') | |
| 153 | .get ('/permset /?filter=e q(%22statu s%22%2C%22 active%22) ') | |
| 154 | .rep ly(200, _. clone(test Data.permi ssionSet)) ; | |
| 155 | ||
| 156 | nock('http :// IP ') | |
| 157 | .get('/ehm pusers/urn :va:user: REDACTED :0001') | |
| 158 | .rep ly(200, _. clone(pjds .defaults. user)); | |
| 159 | ||
| 160 | nock('http :// IP ') | |
| 161 | .put('/ehm pusers/urn :va:user: REDACTED :0001') | |
| 162 | .rep ly(201, {} ); | |
| 163 | ||
| 164 | nock('http :// IP ') | |
| 165 | .get('/ehm pusers/urn :va:user: REDACTED :0002') | |
| 166 | .rep ly(200, _. clone(pjds .defaults. user)); | |
| 167 | ||
| 168 | nock('http :// IP ') | |
| 169 | .put('/ehm pusers/urn :va:user: REDACTED :0002') | |
| 170 | .rep ly(201, {} ); | |
| 171 | ||
| 172 | nock('http :// IP ') | |
| 173 | .get('/ehm pusers/urn :va:user: REDACTED :0003') | |
| 174 | .rep ly(200, _. clone(pjds .defaults. user)); | |
| 175 | ||
| 176 | nock('http :// IP ') | |
| 177 | .put('/ehm pusers/urn :va:user: REDACTED :0003') | |
| 178 | .rep ly(201, {} ); | |
| 179 | ||
| 180 | res.rdkS end = func tion(respo nse) { | |
| 181 | var users = _. get(respon se, ['data ', 'edited Users']); | |
| 182 | expe ct(_.size( users)).to .be(3); | |
| 183 | expe ct(_.get(r esponse, [ 'data', 'e ditedUsers ', 0])).to .have.ownP roperty('u id'); | |
| 184 | done (); | |
| 185 | }; | |
| 186 | ||
| 187 | multiUse rEdit(req, res); | |
| 188 | }) ; | |
| 189 | }); | |
| 190 | ||
| 191 | descri be('when m issing \'a cc\' permi ssion set' , function () { | |
| 192 | be foreEach(f unction() { | |
| 193 | _.set(re q, 'query' , { | |
| 194 | user : {}, | |
| 195 | mode : 'add', | |
| 196 | perm issionSets : ['contes tant-at-ea ting'], | |
| 197 | addi tionalPerm issions: [ 'pie-is-gr eat'] | |
| 198 | }); | |
| 199 | }) ; | |
| 200 | ||
| 201 | it ('does not allow a u ser to edi t their ow n permissi ons withou t \'edit-o wn-permiss ions\'', f unction(do ne) { | |
| 202 | _.set(re q, ['query ', 'users' , 0, 'uid' ], testDat a.actingUs er.uid); | |
| 203 | ||
| 204 | nock('http :// IP ') | |
| 205 | .get ('/permset /?filter=e q(%22statu s%22%2C%22 active%22) ') | |
| 206 | .rep ly(200, _. clone(test Data.permi ssionSet)) ; | |
| 207 | ||
| 208 | nock('http :// IP ') | |
| 209 | .get('/ehm pusers/urn :va:user: REDACTED :0007') | |
| 210 | .rep ly(200, _. clone(test Data.actin gUser)); | |
| 211 | ||
| 212 | res.rdkS end = func tion(respo nse) { | |
| 213 | expe ct(_.get(r esponse, [ 'data', 'f ailedOnEdi tUsers', 0 , 'errorMe ssage'])). to.match(/ Not allowe d to edit your own p ermissions /); | |
| 214 | done (); | |
| 215 | }; | |
| 216 | multiUse rEdit(req, res); | |
| 217 | }) ; | |
| 218 | ||
| 219 | it ('does all ow a user to edit th eir own pe rmissions with \'edi t-own-perm issions\'' , function (done) { | |
| 220 | _.set(re q, ['query ', 'users' , 0, 'uid' ], testDat a.actingUs er.uid); | |
| 221 | _.set(re q, ['sessi on', 'user ', 'permis sionSet', 'additiona lPermissio ns', 0], ' edit-own-p ermissions '); | |
| 222 | _.set(re q, 'sessio n.user.per missions', ['edit-ow n-permissi ons']); | |
| 223 | ||
| 224 | nock('http :// IP ') | |
| 225 | .get ('/permset /?filter=e q(%22statu s%22%2C%22 active%22) ') | |
| 226 | .rep ly(200, _. clone(test Data.permi ssionSet)) ; | |
| 227 | ||
| 228 | nock('http :// IP ') | |
| 229 | .get('/ehm pusers/urn :va:user: REDACTED :0007') | |
| 230 | .rep ly(200, _. clone(test Data.actin gUser)); | |
| 231 | ||
| 232 | nock('http :// IP ') | |
| 233 | .put('/ehm pusers/urn :va:user: REDACTED :0007') | |
| 234 | .rep ly(201, {} ); | |
| 235 | ||
| 236 | res.rdkS end = func tion(respo nse) { | |
| 237 | expe ct(_.get(r esponse, [ 'data', 'e ditedUsers ', 0])).to .have.ownP roperty('u id', testD ata.acting User.uid); | |
| 238 | done (); | |
| 239 | }; | |
| 240 | ||
| 241 | multiUse rEdit(req, res); | |
| 242 | }) ; | |
| 243 | }); | |
| 244 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.