@@ -16,6 +16,7 @@ import {ClientModelAPI} from '../../src/model/clients'
16
16
import { ContactGroupModelAPI } from '../../src/model/contactGroups'
17
17
import { MediatorModelAPI } from '../../src/model/mediators'
18
18
import { UserModelAPI } from '../../src/model/users'
19
+ import { PassportModelAPI } from '../../src/model/passport'
19
20
import * as polling from '../../src/polling'
20
21
21
22
const sampleMetadata = {
@@ -89,6 +90,12 @@ const sampleMetadata = {
89
90
groups : [ 'admin' , 'RHIE' ]
90
91
}
91
92
] ,
93
+ Passports : [
94
+ {
95
+
96
+ protocol : 'local'
97
+ }
98
+ ] ,
92
99
ContactGroups : [
93
100
{
94
101
group : 'Group 1' ,
@@ -101,6 +108,11 @@ const sampleMetadata = {
101
108
{ user : 'User 6' , method : 'email' , maxAlerts : '1 per day' }
102
109
]
103
110
}
111
+ ] ,
112
+ Keystore : [
113
+ {
114
+ key : 'Key'
115
+ }
104
116
]
105
117
}
106
118
@@ -112,6 +124,7 @@ describe('API Integration Tests', () => {
112
124
nonRootCookie = ''
113
125
114
126
before ( async ( ) => {
127
+ await PassportModelAPI . deleteMany ( { } )
115
128
await promisify ( server . start ) ( { apiPort : SERVER_PORTS . apiPort } )
116
129
await testUtils . setupTestUsers ( )
117
130
} )
@@ -216,6 +229,17 @@ describe('API Integration Tests', () => {
216
229
} )
217
230
} )
218
231
232
+ describe ( 'Passports' , ( ) => {
233
+ it ( 'should fetch passports and return status 200' , async ( ) => {
234
+ const res = await request ( BASE_URL )
235
+ . get ( '/metadata' )
236
+ . set ( 'Cookie' , rootCookie )
237
+ . expect ( 200 )
238
+
239
+ res . body [ 0 ] . Passports . length . should . equal ( 2 )
240
+ } )
241
+ } )
242
+
219
243
describe ( 'ContactGroups' , ( ) => {
220
244
beforeEach ( async ( ) => {
221
245
await new ContactGroupModelAPI ( sampleMetadata . ContactGroups [ 0 ] ) . save ( )
@@ -724,10 +748,103 @@ describe('API Integration Tests', () => {
724
748
// POST TO VALIDATE METADATA TESTS
725
749
describe ( '*validateMetadata' , ( ) => {
726
750
beforeEach ( async ( ) => {
751
+ await PassportModelAPI . deleteMany ( )
727
752
await testUtils . cleanupAllTestUsers ( )
728
753
await testUtils . setupTestUsers ( )
729
754
} )
730
755
756
+ const sampleMetadata = {
757
+ Channels : [
758
+ {
759
+ name : 'TestChannel1' ,
760
+ urlPattern : 'test/sample' ,
761
+ allow : [ 'PoC' , 'Test1' , 'Test2' ] ,
762
+ routes : [
763
+ { name : 'test route' , host : 'localhost' , port : 9876 , primary : true }
764
+ ] ,
765
+ txViewAcl : 'group1' ,
766
+ updatedBy : {
767
+ id : new ObjectId ( ) ,
768
+ name : 'Test'
769
+ }
770
+ }
771
+ ] ,
772
+ Clients : [
773
+ {
774
+ clientID : 'YUIAIIIICIIAIA' ,
775
+ clientDomain : 'him.jembi.org' ,
776
+ name : 'OpenMRS Ishmael instance' ,
777
+ roles : [ 'OpenMRS_PoC' , 'PoC' ] ,
778
+ passwordHash :
779
+ '$2a$10$w8GyqInkl72LMIQNpMM/fenF6VsVukyya.c6fh/GRtrKq05C2.Zgy' ,
780
+ certFingerprint :
781
+ '23:37:6A:5E:A9:13:A4:8C:66:C5:BB:9F:0E:0D:68:9B:99:80:10:FC'
782
+ }
783
+ ] ,
784
+ Mediators : [
785
+ {
786
+ urn : 'urn:uuid:EEA84E13-1C92-467C-B0BD-7C480462D1ED' ,
787
+ version : '1.0.0' ,
788
+ name : 'Save Encounter Mediator' ,
789
+ description : 'A mediator for testing' ,
790
+ endpoints : [
791
+ {
792
+ name : 'Save Encounter' ,
793
+ host : 'localhost' ,
794
+ port : '8005' ,
795
+ type : 'http'
796
+ }
797
+ ] ,
798
+ defaultChannelConfig : [
799
+ {
800
+ name : 'Save Encounter 1' ,
801
+ urlPattern : '/encounters' ,
802
+ type : 'http' ,
803
+ allow : [ ] ,
804
+ routes : [
805
+ {
806
+ name : 'Save Encounter 1' ,
807
+ host : 'localhost' ,
808
+ port : '8005' ,
809
+ type : 'http'
810
+ }
811
+ ]
812
+ }
813
+ ]
814
+ }
815
+ ] ,
816
+ Users : [
817
+ {
818
+ firstname : 'Namey' ,
819
+ surname : 'mcTestName' ,
820
+
821
+ passwordAlgorithm : 'sha512' ,
822
+ passwordHash : '796a5a8e-4e44-4d9f-9e04-c27ec6374ffa' ,
823
+ passwordSalt : 'bf93caba-6eec-4c0c-a1a3-d968a7533fd7' ,
824
+ groups : [ 'admin' , 'RHIE' ]
825
+ }
826
+ ] ,
827
+ Passports : [
828
+ {
829
+
830
+ protocol : 'local'
831
+ }
832
+ ] ,
833
+ ContactGroups : [
834
+ {
835
+ group : 'Group 1' ,
836
+ users : [
837
+ { user : 'User 1' , method : 'sms' , maxAlerts : 'no max' } ,
838
+ { user : 'User 2' , method : 'email' , maxAlerts : '1 per hour' } ,
839
+ { user : 'User 3' , method : 'sms' , maxAlerts : '1 per day' } ,
840
+ { user : 'User 4' , method : 'email' , maxAlerts : 'no max' } ,
841
+ { user : 'User 5' , method : 'sms' , maxAlerts : '1 per hour' } ,
842
+ { user : 'User 6' , method : 'email' , maxAlerts : '1 per day' }
843
+ ]
844
+ }
845
+ ]
846
+ }
847
+
731
848
it ( 'should validate metadata and return status 201' , async ( ) => {
732
849
const res = await request ( BASE_URL )
733
850
. post ( '/metadata/validate' )
@@ -741,7 +858,7 @@ describe('API Integration Tests', () => {
741
858
statusCheckObj [ doc . status ] += 1
742
859
}
743
860
744
- statusCheckObj . Valid . should . equal ( 5 )
861
+ statusCheckObj . Valid . should . equal ( 6 )
745
862
statusCheckObj . Conflict . should . equal ( 0 )
746
863
statusCheckObj . Error . should . equal ( 0 )
747
864
} )
@@ -762,7 +879,7 @@ describe('API Integration Tests', () => {
762
879
statusCheckObj [ doc . status ] += 1
763
880
}
764
881
765
- statusCheckObj . Valid . should . equal ( 4 )
882
+ statusCheckObj . Valid . should . equal ( 5 )
766
883
statusCheckObj . Conflict . should . equal ( 0 )
767
884
statusCheckObj . Error . should . equal ( 1 )
768
885
} )
@@ -787,7 +904,7 @@ describe('API Integration Tests', () => {
787
904
statusCheckObj [ doc . status ] += 1
788
905
}
789
906
790
- statusCheckObj . Valid . should . equal ( 4 )
907
+ statusCheckObj . Valid . should . equal ( 5 )
791
908
statusCheckObj . Conflict . should . equal ( 1 )
792
909
statusCheckObj . Error . should . equal ( 0 )
793
910
ChannelModelAPI . deleteMany ( { } )
0 commit comments