File tree Expand file tree Collapse file tree 1 file changed +70
-0
lines changed Expand file tree Collapse file tree 1 file changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -682,5 +682,75 @@ describe(
682
682
} ) ;
683
683
}
684
684
} ) ;
685
+
686
+ describe ( 'Views are prohibited' , function ( ) {
687
+ before ( function ( ) {
688
+ // First, perform the setup.
689
+
690
+ // #. Create a MongoClient without encryption enabled (referred to as ``client``).
691
+ this . client = this . configuration . newClient (
692
+ { } ,
693
+ { useNewUrlParser : true , useUnifiedTopology : true }
694
+ ) ;
695
+
696
+ return this . client
697
+ . connect ( )
698
+ . then ( ( ) => {
699
+ return this . client
700
+ . db ( dataDbName )
701
+ . dropCollection ( dataCollName )
702
+ . catch ( noop ) ;
703
+ } )
704
+ . then ( ( ) => {
705
+ return this . client . db ( dataDbName ) . createCollection ( dataCollName ) ;
706
+ } )
707
+ . then ( ( ) => {
708
+ return this . client
709
+ . db ( dataDbName )
710
+ . createCollection ( 'view' , { viewOn : dataCollName , pipeline : [ ] } ) ;
711
+ } ) ;
712
+ } ) ;
713
+
714
+ after ( function ( ) {
715
+ return this . client && this . client . close ( ) ;
716
+ } ) ;
717
+
718
+ beforeEach ( function ( ) {
719
+ this . clientEncrypted = this . configuration . newClient (
720
+ { } ,
721
+ {
722
+ useNewUrlParser : true ,
723
+ useUnifiedTopology : true ,
724
+ autoEncryption : {
725
+ keyVaultNamespace,
726
+ kmsProviders
727
+ }
728
+ }
729
+ ) ;
730
+
731
+ return this . clientEncrypted . connect ( ) ;
732
+ } ) ;
733
+
734
+ afterEach ( function ( ) {
735
+ return this . clientEncrypted && this . clientEncrypted . close ( ) ;
736
+ } ) ;
737
+
738
+ it ( 'should error when inserting into a view with autoEncryption' , function ( ) {
739
+ this . clientEncrypted
740
+ . db ( dataDbName )
741
+ . collection ( 'view' )
742
+ . insertOne ( { a : 1 } )
743
+ . then (
744
+ ( ) => {
745
+ throw new Error ( 'Expected insert to fail, but it succeeded' ) ;
746
+ } ,
747
+ err => {
748
+ expect ( err )
749
+ . to . have . property ( 'message' )
750
+ . that . matches ( / c a n n o t a u t o e n c r y p t a v i e w / ) ;
751
+ }
752
+ ) ;
753
+ } ) ;
754
+ } ) ;
685
755
}
686
756
) ;
You can’t perform that action at this time.
0 commit comments