@@ -4,7 +4,6 @@ import yaml from "js-yaml";
44import * as path from "path" ;
55import { Config , loadConfiguration } from "../../config" ;
66import * as config from "../../config" ;
7- import * as keyvault from "../../lib/azure/keyvault" ;
87import * as storage from "../../lib/azure/storage" ;
98import { createTempDir } from "../../lib/ioUtil" ;
109import { deepClone } from "../../lib/util" ;
@@ -15,7 +14,6 @@ import {
1514} from "../../logger" ;
1615import { AzureAccessOpts , ConfigYaml } from "../../types" ;
1716import {
18- createKeyVault ,
1917 execute ,
2018 getStorageAccessKey ,
2119 CommandOptions ,
@@ -37,7 +35,6 @@ afterAll(() => {
3735} ) ;
3836
3937const MOCKED_VALUES : CommandOptions = {
40- keyVaultName : "testKeyVault" ,
4138 servicePrincipalId : "servicePrincipalId" ,
4239 servicePrincipalPassword : "servicePrincipalPassword" ,
4340 storageAccountName : "testaccount" ,
@@ -49,7 +46,6 @@ const MOCKED_VALUES: CommandOptions = {
4946} ;
5047
5148const MOCKED_CONFIG : OnBoardConfig = {
52- keyVaultName : "testKeyVault" ,
5349 servicePrincipalId : "servicePrincipalId" ,
5450 servicePrincipalPassword : "servicePrincipalPassword" ,
5551 storageAccountName : "testaccount" ,
@@ -108,7 +104,6 @@ const testPopulatedVal = (
108104describe ( "test populateValues" , ( ) => {
109105 it ( "all values are set" , ( ) => {
110106 const values = populateValues ( getMockedValues ( ) ) ;
111- expect ( values . keyVaultName ) . toBe ( MOCKED_VALUES . keyVaultName ) ;
112107 expect ( values . servicePrincipalId ) . toBe ( MOCKED_VALUES . servicePrincipalId ) ;
113108 expect ( values . servicePrincipalPassword ) . toBe (
114109 MOCKED_VALUES . servicePrincipalPassword
@@ -152,19 +147,6 @@ describe("test populateValues", () => {
152147 }
153148 ) ;
154149 } ) ;
155- it ( "keyVaultName default to config.introspection.azure.key_vault_name" , ( ) => {
156- testPopulatedVal (
157- ( configYaml : ConfigYaml ) => {
158- configYaml . key_vault_name = "KeyVaultName" ;
159- } ,
160- ( values : CommandOptions ) => {
161- values . keyVaultName = undefined ;
162- } ,
163- ( values ) => {
164- expect ( values . keyVaultName ) . toBe ( "KeyVaultName" ) ;
165- }
166- ) ;
167- } ) ;
168150 it ( "servicePrincipalId default to config.introspection.azure.service_principal_id" , ( ) => {
169151 testPopulatedVal (
170152 ( configYaml : ConfigYaml ) => {
@@ -316,37 +298,17 @@ describe("test validateAndCreateStorageAccount function", () => {
316298
317299describe ( "test getStorageAccessKey function" , ( ) => {
318300 it ( "already exist" , async ( ) => {
319- jest
320- . spyOn ( storage , "getStorageAccountKey" )
321- . mockReturnValueOnce ( Promise . resolve ( "key" ) ) ;
301+ jest . spyOn ( storage , "getStorageAccountKey" ) . mockResolvedValueOnce ( "key" ) ;
322302 const values = getMockedConfig ( ) ;
323303 const accessOpts = getMockedAccessOpts ( values ) ;
324304 const storageKey = await getStorageAccessKey ( values , accessOpts ) ;
325305 expect ( storageKey ) . toBe ( "key" ) ;
326306 } ) ;
327307} ) ;
328308
329- describe ( "test createKeyVault function" , ( ) => {
330- it ( "[+ve] not key vault value" , async ( ) => {
331- const values = getMockedConfig ( ) ;
332- values . keyVaultName = undefined ;
333- const accessOpts = getMockedAccessOpts ( values ) ;
334- // nothing is done
335- await createKeyVault ( values , accessOpts , "accessString" ) ;
336- } ) ;
337- it ( "[+ve] with key vault value" , async ( ) => {
338- jest . spyOn ( keyvault , "setSecret" ) . mockReturnValueOnce ( Promise . resolve ( ) ) ;
339- const values = getMockedConfig ( ) ;
340- const accessOpts = getMockedAccessOpts ( values ) ;
341- await createKeyVault ( values , accessOpts , "accessString" ) ;
342- } ) ;
343- } ) ;
344-
345309describe ( "onboard" , ( ) => {
346310 test ( "empty location" , async ( ) => {
347- jest
348- . spyOn ( storage , "isStorageAccountExist" )
349- . mockReturnValueOnce ( Promise . resolve ( false ) ) ;
311+ jest . spyOn ( storage , "isStorageAccountExist" ) . mockResolvedValueOnce ( false ) ;
350312
351313 try {
352314 const values = getMockedConfig ( ) ;
@@ -392,9 +354,6 @@ describe("onboard", () => {
392354 jest
393355 . spyOn ( storage , "createStorageAccount" )
394356 . mockReturnValueOnce ( Promise . resolve ( { location : "test" } ) ) ;
395- jest
396- . spyOn ( onboardImpl , "createKeyVault" )
397- . mockReturnValueOnce ( Promise . resolve ( ) ) ;
398357 jest . spyOn ( onboardImpl , "setConfiguration" ) . mockReturnValueOnce ( true ) ;
399358
400359 const data = {
0 commit comments