1
- 'use strict' ;
2
-
3
- let request = require ( 'supertest' ) ,
4
- localAddress = 'http://192.168.6.6:8060' ,
5
- pre3Address = 'http://172.16.3.223:8060' ,
6
- pre1Address = 'http://192.168.40.35:8060' ,
7
- onlineAddress = 'http://open.hmp2.fi.beibei.com' ,
8
- _ = require ( 'underscore' ) ,
9
- md5 = require ( 'md5' ) ,
10
- Assert = require ( 'chai' ) . assert ;
11
-
12
- let remote = request ( pre1Address ) ;
13
- describe ( '/server/open/system/purview.js' , function ( ) {
14
- describe ( '#verification' , function ( ) {
15
- it . only ( '/hms/module/dashboard' , function ( done ) {
16
- remote
17
- . get ( '/system/purview/verification' )
18
- . query ( {
19
- type : 'url' ,
20
- key : '/hms/module/dashboard' ,
21
- uid : 402 ,
22
- app_id : 1 ,
23
- sign : md5 ( 'key=/hms/module/dashboard;type=url;uid=402;ycz73g8xcKUnduVK9kpA9a' )
24
- } )
25
- . end ( ( err , res ) => {
26
- Assert . isNull ( err , 'should be null' ) ;
27
- Assert . isOk ( res . body . status , 'should be true' ) ;
28
- Assert . isOk ( res . body . result , 'should be true' ) ;
29
- Assert . equal ( 'N.T.T' , res . body . detail , 'should be N.T.T' ) ;
30
- done ( ) ;
31
- } ) ;
32
- } ) ;
33
- } ) ;
34
-
35
- describe ( '#batchVerification' , function ( ) {
36
- it ( 'should return a batchVerification result' , function ( done ) {
37
- remote
38
- . get ( '/system/purview/batchVerification' )
39
- . query ( {
40
- type : 'item' ,
41
- key : 'dc.sqlList.[9,200,251]' ,
42
- uid : 171 ,
43
- app_id : 1 ,
44
- sign : md5 ( 'key=dc.sqlList.[9,200,251];type=item;uid=171;ycz73g8xcKUnduVK9kpA9a' )
45
- } )
46
- . end ( ( err , res ) => {
47
- Assert . isNull ( err , 'should be null' ) ;
48
- Assert . isOk ( res . body . status , 'should be true' ) ;
49
- Assert . equal ( '["T.N.N","T.N.N","T.N.N"]' , res . body . detail , 'should be ["T.N.N","T.N.N","T.N.N"]' ) ;
50
- done ( ) ;
51
- } ) ;
52
- } ) ;
53
- } ) ;
54
-
55
- describe ( '#authorizeList' , function ( ) {
56
- it ( 'should get user accessable list' , function ( done ) {
57
- remote
58
- . get ( '/system/purview/authorizeList' )
59
- . query ( {
60
- list : 'dc.sqlList' ,
61
- uid : 180 ,
62
- page : 1 ,
63
- size : 5 ,
64
- app_id : 1 ,
65
- sign : md5 ( 'list=dc.sqlList;page=1;size=5;uid=180;ycz73g8xcKUnduVK9kpA9a' )
66
- } )
67
- . end ( ( err , res ) => {
68
- Assert . isNull ( err , 'should be null' ) ;
69
- Assert . isOk ( res . body . status , 'should be true' ) ;
70
- Assert . equal ( '55;93;94;123;150' , res . body . items . join ( ';' ) , 'should be equal 55;93;94;123;150' ) ;
71
- done ( ) ;
72
- } ) ;
73
- } ) ;
74
- } ) ;
75
-
76
- describe ( '#userDetail' , function ( ) {
77
- it ( 'should return user purview detail' , function ( done ) {
78
- remote
79
- . get ( '/system/purview/userDetail' )
80
- . query ( {
81
- app_id : 1 ,
82
- uid : 111 ,
83
- sign : md5 ( 'uid=111;ycz73g8xcKUnduVK9kpA9a' )
84
- } )
85
- . end ( ( err , res ) => {
86
- Assert . isNull ( err , 'should be null' ) ;
87
- Assert . equal ( '1;4' , res . body . data . app . join ( ';' ) , 'should equal 1;4' ) ;
88
- Assert . isArray ( res . body . data . role , 'should be array' ) ;
89
- done ( ) ;
90
- } ) ;
91
- } ) ;
92
- } ) ;
93
-
94
- describe ( '#create' , function ( ) {
95
- it ( 'should create a purview' , function ( done ) {
96
- remote
97
- . get ( '/system/purview/create' )
98
- . query ( {
99
- key : 'dc.sqlList.1010' ,
100
- tactics : false ,
101
- app_id : 1 ,
102
- type : 'item' ,
103
- sign : md5 ( 'key=dc.sqlList.1010;tactics=false;type=item;ycz73g8xcKUnduVK9kpA9a' )
104
- } )
105
- . end ( ( err , res ) => {
106
- Assert . isOk ( res . body . status , 'should be ok' ) ;
107
- // Assert.equal('exist the same key', res.body.msg,'should be equal [exist the same key]');
108
- Assert . isNull ( err , 'should be null' ) ;
109
- done ( ) ;
110
- } ) ;
111
- } ) ;
112
- } ) ;
113
-
114
- describe ( '#modify' , function ( ) {
115
- it ( 'should create a purview' , function ( done ) {
116
- remote
117
- . get ( '/system/purview/modify' )
118
- . query ( {
119
- key : 'dc.sqlList.1010' ,
120
- tactics : true ,
121
- app_id : 1 ,
122
- sign : md5 ( 'key=dc.sqlList.1010;tactics=true;ycz73g8xcKUnduVK9kpA9a' )
123
- } )
124
- . end ( ( err , res ) => {
125
- console . log ( 'err>' , err ) ;
126
- console . log ( 'res>' , res . body ) ;
127
- Assert . isNull ( err , 'should be null' ) ;
128
- Assert . isOk ( res . body . status , 'should be ok' ) ;
129
- done ( ) ;
130
- } ) ;
131
- } ) ;
132
- } ) ;
133
-
134
- describe ( '#delete' , function ( ) {
135
- it ( 'should delete a purview' , function ( done ) {
136
- remote
137
- . get ( '/system/purview/delete' )
138
- . query ( {
139
- key : 'dc.sqlList.1010' ,
140
- app_id : 1 ,
141
- sign : md5 ( 'key=dc.sqlList.1010;ycz73g8xcKUnduVK9kpA9a' )
142
- } )
143
- . end ( ( err , res ) => {
144
- Assert . isNull ( err , 'should be null' ) ;
145
- Assert . isOk ( res . body . status , 'should be ok' ) ;
146
- done ( ) ;
147
- } ) ;
148
- } ) ;
149
- } ) ;
150
-
151
- describe ( '#queryRoles' , function ( ) {
152
- it ( 'should return roles list' , function ( done ) {
153
- remote
154
- . get ( '/system/purview/queryRoles' )
155
- . query ( {
156
- app_id : 1 ,
157
- _page : 1 ,
158
- role : '运营' ,
159
- _size : 20 ,
160
- sign : md5 ( `app_id=1;_page=1;role=运营;_size=20;ycz73g8xcKUnduVK9kpA9a` )
161
- } )
162
- . end ( ( err , res ) => {
163
- Assert . isNull ( err , 'should be null' ) ;
164
- Assert . isOk ( res . body . status , 'should be ok' ) ;
165
- Assert . equal ( '17;18;31' , res . body . role [ 0 ] . gp , 'should be equal 17;18;31' ) ;
166
- done ( ) ;
167
- } ) ;
168
- } ) ;
169
- } ) ;
170
-
171
- describe ( '#applyRole' , function ( ) {
172
- it ( 'should receive a mail' , function ( done ) {
173
- this . timeout ( 3000 ) ;
174
-
175
- remote
176
- . get ( '/system/purview/applyRole' )
177
- . query ( {
178
- app_id : 1 ,
179
- uid : 1404 ,
180
- uname : '冯春艳' ,
181
- roleid : 7 ,
182
- rolename : '公司管理层' ,
183
- applystatus : 'wconfirm' ,
184
- sign : md5 ( `uid=1404;uname=冯春艳;roleid=7;rolename=公司管理层;applystatus=wconfirm;ycz73g8xcKUnduVK9kpA9a` )
185
- } )
186
- . end ( ( err , res ) => {
187
- Assert . isNull ( err , 'should be null' ) ;
188
- Assert . isOk ( res . body . status , 'should be ok' ) ;
189
- done ( ) ;
190
- } ) ;
191
- } ) ;
192
- } ) ;
193
-
194
- describe ( '#confirmApply' , function ( ) {
195
- it ( 'should change purviewroleapply status' , function ( done ) {
196
-
197
- remote
198
- . get ( '/system/purview/confirmApply' )
199
- . query ( {
200
- app_id : 1 ,
201
- id : 31 ,
202
- uid : 1404 ,
203
- roleid : 7 ,
204
- checker : '赵朋' ,
205
- applystatus : 'agree' ,
206
- sign : md5 ( `app_id=1;checker=赵朋;id=31;roleid=7;uid=1404;ycz73g8xcKUnduVK9kpA9a` )
207
- } )
208
- . end ( ( err , res ) => {
209
- Assert . isNull ( err , 'should be null' ) ;
210
- Assert . equal ( 'not found purviewRoleApply record' , res . body . msg ) ;
211
- done ( ) ;
212
- } ) ;
213
- } ) ;
214
- } ) ;
215
-
216
- describe ( '#cancelRole' , function ( ) {
217
- it ( 'should cancel specified user role' , function ( done ) {
218
-
219
- remote
220
- . get ( '/system/purview/cancelRole' )
221
- . query ( {
222
- app_id : 1 ,
223
- uid : 870 ,
224
- roleid : 6 ,
225
- sign : md5 ( `app_id=1;roleid=6;uid=870;ycz73g8xcKUnduVK9kpA9a` )
226
- } )
227
- . end ( ( err , res ) => {
228
- Assert . isNull ( err , 'should be null' ) ;
229
- Assert . isOk ( res . body . status , 'should be ok' ) ;
230
- done ( ) ;
231
- } ) ;
232
- } ) ;
233
- } ) ;
234
-
235
- describe ( '#queryApplyRecords' , function ( ) {
236
- it ( 'should return 1 page apply reocrds' , function ( done ) {
237
-
238
- remote
239
- . get ( '/system/purview/queryApplyRecords' )
240
- . query ( {
241
- _size : 10 ,
242
- _page : 1
243
- } )
244
- . end ( ( err , res ) => {
245
- Assert . isNull ( err , 'should be null' ) ;
246
- Assert . isOk ( res . body . status , 'should be ok' ) ;
247
- Assert . equal ( 10 , res . body . size , 'should be 10' ) ;
248
- Assert . isArray ( res . body . list , 'should be an array' ) ;
249
- done ( ) ;
250
- } ) ;
251
- } ) ;
252
- } ) ;
253
- } ) ;
0 commit comments