1
+ const path = require ( 'path' ) ;
2
+
1
3
describe ( 'secure-config multiconf feature test suite (v2 features)' , ( ) => {
2
4
3
5
const myconfKey = '11c4b6c3cdb7ebaff74a7a340d30c45fd2f7a49d6d0b56badb300dbe49f233ec' ;
@@ -95,4 +97,30 @@ describe('secure-config multiconf feature test suite (v2 features)', () => {
95
97
expect ( myconf . database . password ) . toBe ( 'SecretPassword-Prod' ) ;
96
98
} ) ;
97
99
100
+ it ( 'tests a successful production configuration retrieval with custom file prefix and custom directory' , ( ) => {
101
+ process . env [ 'CONFIG_ENCRYPTION_KEY' ] = myconfKey ;
102
+ const conf = require ( '../secure-config' ) ( { prefix : 'myconf' , directory : path . join ( process . cwd ( ) , 'test/configurations' ) } ) ;
103
+ expect ( conf . info ) . toEqual ( 'myconf-custom-dir' ) ;
104
+ expect ( conf . database . host ) . toBe ( '127.0.0.1' ) ;
105
+ expect ( conf . database . user ) . toBe ( 'SecretUser' ) ;
106
+ expect ( conf . database . password ) . toBe ( 'SecretPassword' ) ;
107
+ expect ( conf . filestorage . type ) . toBe ( 'local' ) ;
108
+ expect ( conf . filestorage . params . folder ) . toBe ( '/tmp/storage' ) ;
109
+ expect ( conf . filestorage . params . storagepass ) . toBe ( 'StoragePassword' ) ;
110
+ expect ( conf . testarray ) . toBeDefined ( ) ;
111
+ expect ( Array . isArray ( conf . testarray ) ) . toBeTruthy ( ) ;
112
+ expect ( conf . testarray . length ) . toBe ( 6 ) ;
113
+ expect ( conf . testarray [ 0 ] ) . toEqual ( 'one' ) ;
114
+ expect ( conf . testarray [ 1 ] ) . toEqual ( 'two' ) ;
115
+ expect ( conf . testarray [ 2 ] ) . toEqual ( 'three' ) ;
116
+ expect ( conf . testarray [ 3 ] . arrayItemKey ) . toEqual ( 'itemValue1' ) ;
117
+ expect ( conf . testarray [ 3 ] . additionalItem1 ) . toEqual ( 'value1' ) ;
118
+ expect ( conf . testarray [ 4 ] . arrayItemKey ) . toEqual ( 'itemValue2' ) ;
119
+ expect ( conf . testarray [ 4 ] . additionalItem1 ) . toEqual ( 'value1' ) ;
120
+ expect ( conf . testarray [ 4 ] . additionalItem2 ) . toEqual ( 12 ) ;
121
+ expect ( conf . testarray [ 5 ] . length ) . toEqual ( 1 ) ;
122
+ expect ( conf . testarray [ 5 ] [ 0 ] . subArrayItemKey ) . toEqual ( 'subArrayItemValue' ) ;
123
+ expect ( conf . nullvalue ) . toBe ( null ) ;
124
+ } ) ;
125
+
98
126
} ) ;
0 commit comments