@@ -738,6 +738,96 @@ describe('node-vault', () => {
738738 } ) ;
739739 } ) ;
740740
741+ describe ( 'transit commands' , ( ) => {
742+ it ( 'should have rewrapData function' , ( ) => {
743+ vault . rewrapData . should . be . a ( 'function' ) ;
744+ } ) ;
745+
746+ it ( 'should have transitCreateKey function' , ( ) => {
747+ vault . transitCreateKey . should . be . a ( 'function' ) ;
748+ } ) ;
749+
750+ it ( 'should have transitReadKey function' , ( ) => {
751+ vault . transitReadKey . should . be . a ( 'function' ) ;
752+ } ) ;
753+
754+ it ( 'should have transitListKeys function' , ( ) => {
755+ vault . transitListKeys . should . be . a ( 'function' ) ;
756+ } ) ;
757+
758+ it ( 'should have transitDeleteKey function' , ( ) => {
759+ vault . transitDeleteKey . should . be . a ( 'function' ) ;
760+ } ) ;
761+
762+ it ( 'should call rewrapData with correct path and method' , ( done ) => {
763+ const params = {
764+ method : 'POST' ,
765+ path : '/transit/rewrap/mykey' ,
766+ } ;
767+ vault . rewrapData ( { name : 'mykey' , ciphertext : 'vault:v1:abc' } )
768+ . then ( assertRequest ( request , params , done ) )
769+ . catch ( done ) ;
770+ } ) ;
771+
772+ it ( 'should call transitListKeys with correct method' , ( done ) => {
773+ const params = {
774+ method : 'LIST' ,
775+ path : '/transit/keys' ,
776+ } ;
777+ vault . transitListKeys ( )
778+ . then ( assertRequest ( request , params , done ) )
779+ . catch ( done ) ;
780+ } ) ;
781+
782+ it ( 'should call transitReadKey with correct path' , ( done ) => {
783+ const params = {
784+ method : 'GET' ,
785+ path : '/transit/keys/mykey' ,
786+ } ;
787+ vault . transitReadKey ( { name : 'mykey' } )
788+ . then ( assertRequest ( request , params , done ) )
789+ . catch ( done ) ;
790+ } ) ;
791+
792+ it ( 'should call transitCreateKey with correct path and method' , ( done ) => {
793+ const params = {
794+ method : 'POST' ,
795+ path : '/transit/keys/mykey' ,
796+ } ;
797+ vault . transitCreateKey ( { name : 'mykey' , type : 'aes256-gcm96' } )
798+ . then ( assertRequest ( request , params , done ) )
799+ . catch ( done ) ;
800+ } ) ;
801+
802+ it ( 'should call transitDeleteKey with correct path and method' , ( done ) => {
803+ const params = {
804+ method : 'DELETE' ,
805+ path : '/transit/keys/mykey' ,
806+ } ;
807+ vault . transitDeleteKey ( { name : 'mykey' } )
808+ . then ( assertRequest ( request , params , done ) )
809+ . catch ( done ) ;
810+ } ) ;
811+ } ) ;
812+
813+ describe ( 'commands export' , ( ) => {
814+ it ( 'should expose commands object on client' , ( ) => {
815+ vault . commands . should . be . an ( 'object' ) ;
816+ } ) ;
817+
818+ it ( 'should include encryptData in commands' , ( ) => {
819+ vault . commands . encryptData . should . be . an ( 'object' ) ;
820+ vault . commands . encryptData . method . should . equal ( 'POST' ) ;
821+ vault . commands . encryptData . path . should . equal ( '/transit/encrypt/{{name}}' ) ;
822+ } ) ;
823+
824+ it ( 'should include rewrapData in commands' , ( ) => {
825+ vault . commands . rewrapData . should . be . an ( 'object' ) ;
826+ vault . commands . rewrapData . method . should . equal ( 'POST' ) ;
827+ vault . commands . rewrapData . path . should . equal ( '/transit/rewrap/{{name}}' ) ;
828+ } ) ;
829+ } ) ;
830+
741831 describe ( 'request(options)' , ( ) => {
742832 it ( 'should reject if options are undefined' , ( done ) => {
743833 vault . request ( )
0 commit comments