@@ -99,48 +99,17 @@ ava.serial('vault credential password life cycle', async t => {
9999 await tests . remove ( 'vault' , vault ) ;
100100} ) ;
101101
102- [ 'project' , 'user' ] . forEach ( type => {
103- ava . serial ( `vault credential ${ type } ssh use` , async t => {
104- const name = tests . getName ( t . title ) ;
105- const sshKeyPair = await ssh . generateKey ( ) ;
106- const sshFilename = tests . getRandomFile ( sshKeyPair . publicKey ) ;
102+ ava . serial ( 'vault ssh using cert' , async t => {
103+ const { privateKey, publicKey } = await ssh . generateKey ( ) ;
107104
108- const ssh_name = `${ name } -${ type } -key` ;
109- const credentials = await tests . run ( `${ type } credentials add --name ${ ssh_name } --sshkey-file '${ sshFilename } '` ) ;
110- const vault = await tests . run ( `vault create --name ${ name } --size 10 --ssh ${ ssh_name } ` ) ;
111-
112- const list = await tests . run ( `vault credential cert list --vault ${ vault . id } ` ) ;
113- t . true ( list . some ( p => p . name === ssh_name ) ) ;
114-
115- await tests . remove ( `${ type } credentials` , credentials ) ;
116- await tests . remove ( 'vault' , vault ) ;
117-
118- fs . unlinkSync ( sshFilename ) ;
119- } ) ;
120- } ) ;
121-
122- [ 'project' , 'user' ] . forEach ( type => {
123- ava . serial ( `vault ssh using ${ type } ssh-key` , async t => {
124- const sshKeyPair = await ssh . generateKey ( ) ;
125- const sshFilename = tests . getRandomFile ( sshKeyPair . publicKey ) ;
126-
127- const name = tests . getName ( t . title ) ;
128- const ssh_name = `${ name } -${ type } -key` ;
129-
130- const credentials = await tests . run ( `${ type } credentials add --name ${ ssh_name } --sshkey-file '${ sshFilename } '` ) ;
131-
132- const vault = await tests . run ( `vault create --name ${ name } --size 10 --ssh ${ ssh_name } ` ) ;
105+ const name = tests . getName ( t . title ) ;
133106
134- const content = await ssh . execResource ( vault , {
135- privateKey : sshKeyPair . privateKey ,
136- } , 'uptime' ) ;
137- t . true ( content . includes ( 'load average' ) , content ) ;
107+ const vault = await tests . run ( `vault create --name ${ name } --size 10 --ssh '${ publicKey } '` ) ;
138108
139- fs . unlinkSync ( sshFilename ) ;
109+ const content = await ssh . execResource ( vault , { privateKey} , 'uptime' ) ;
110+ t . true ( content . includes ( 'load average' ) , content ) ;
140111
141- await tests . remove ( `${ type } credentials` , credentials ) ;
142- await tests . remove ( 'vault' , vault ) ;
143- } ) ;
112+ await tests . remove ( 'vault' , vault ) ;
144113} ) ;
145114
146115ava . serial ( 'vault ssh using password' , async t => {
0 commit comments