2929 },
3030 }
3131
32+ typedPassword = & targets.SessionCredential {
33+ CredentialSource : & targets.CredentialSource {
34+ CredentialType : passwordCredentialType ,
35+ },
36+ Credential : map [string ]any {
37+ "password" : "pass" ,
38+ },
39+ }
40+
3241 typedSshPrivateKey = & targets.SessionCredential {
3342 CredentialSource : & targets.CredentialSource {
3443 CredentialType : sshPrivateKeyCredentialType ,
7584 },
7685 }
7786
87+ vaultPassword = & targets.SessionCredential {
88+ CredentialSource : & targets.CredentialSource {
89+ Type : vaultGenericLibrarySubtype ,
90+ },
91+ Secret : & targets.SessionSecret {
92+ Decoded : map [string ]any {
93+ "password" : "vault-decoded-pass" ,
94+ },
95+ },
96+ }
97+
7898 vaultSshPrivateKey = & targets.SessionCredential {
7999 CredentialSource : & targets.CredentialSource {
80100 Type : vaultGenericLibrarySubtype ,
@@ -119,6 +139,17 @@ var (
119139 },
120140 }
121141
142+ staticPassword = & targets.SessionCredential {
143+ CredentialSource : & targets.CredentialSource {
144+ Type : staticSubtype ,
145+ },
146+ Secret : & targets.SessionSecret {
147+ Decoded : map [string ]any {
148+ "password" : "static-decoded-pass" ,
149+ },
150+ },
151+ }
152+
122153 staticSshPrivateKey = & targets.SessionCredential {
123154 CredentialSource : & targets.CredentialSource {
124155 Type : staticSubtype ,
@@ -215,6 +246,21 @@ func Test_parseCredentials(t *testing.T) {
215246 },
216247 wantErr : false ,
217248 },
249+ {
250+ name : "password-typed" ,
251+ creds : []* targets.SessionCredential {
252+ typedPassword ,
253+ },
254+ wantCreds : Credentials {
255+ Password : []Password {
256+ {
257+ Password : "pass" ,
258+ Raw : typedPassword ,
259+ },
260+ },
261+ },
262+ wantErr : false ,
263+ },
218264 {
219265 name : "ssh-private-key-typed" ,
220266 creds : []* targets.SessionCredential {
@@ -247,6 +293,21 @@ func Test_parseCredentials(t *testing.T) {
247293 },
248294 wantErr : false ,
249295 },
296+ {
297+ name : "vault-password-decoded" ,
298+ creds : []* targets.SessionCredential {
299+ vaultPassword ,
300+ },
301+ wantCreds : Credentials {
302+ Password : []Password {
303+ {
304+ Password : "vault-decoded-pass" ,
305+ Raw : vaultPassword ,
306+ },
307+ },
308+ },
309+ wantErr : false ,
310+ },
250311 {
251312 name : "vault-private-key-decoded" ,
252313 creds : []* targets.SessionCredential {
@@ -343,6 +404,21 @@ func Test_parseCredentials(t *testing.T) {
343404 },
344405 wantErr : false ,
345406 },
407+ {
408+ name : "static-password-decoded" ,
409+ creds : []* targets.SessionCredential {
410+ staticPassword ,
411+ },
412+ wantCreds : Credentials {
413+ Password : []Password {
414+ {
415+ Password : "static-decoded-pass" ,
416+ Raw : staticPassword ,
417+ },
418+ },
419+ },
420+ wantErr : false ,
421+ },
346422 {
347423 name : "static-private-key-decoded" ,
348424 creds : []* targets.SessionCredential {
@@ -388,7 +464,7 @@ func Test_parseCredentials(t *testing.T) {
388464 creds : []* targets.SessionCredential {
389465 staticSshPrivateKey , UnspecifiedCred1 , vaultSshPrivateKey , typedUsernamePassword ,
390466 UnspecifiedCred , vaultUsernamePassword , typedSshPrivateKey , staticUsernamePassword ,
391- staticKv ,
467+ staticKv , typedPassword , vaultPassword , staticPassword ,
392468 },
393469 wantCreds : Credentials {
394470 SshPrivateKey : []SshPrivateKey {
@@ -425,6 +501,20 @@ func Test_parseCredentials(t *testing.T) {
425501 Raw : typedUsernamePassword ,
426502 },
427503 },
504+ Password : []Password {
505+ {
506+ Password : "static-decoded-pass" ,
507+ Raw : staticPassword ,
508+ },
509+ {
510+ Password : "vault-decoded-pass" ,
511+ Raw : vaultPassword ,
512+ },
513+ {
514+ Password : "pass" ,
515+ Raw : typedPassword ,
516+ },
517+ },
428518 Unspecified : []* targets.SessionCredential {
429519 UnspecifiedCred , UnspecifiedCred1 , staticKv ,
430520 },
@@ -447,6 +537,7 @@ func Test_parseCredentials(t *testing.T) {
447537 assert .ElementsMatch (tt .wantCreds .UsernamePassword , creds .UsernamePassword )
448538 assert .ElementsMatch (tt .wantCreds .SshPrivateKey , creds .SshPrivateKey )
449539 assert .ElementsMatch (tt .wantCreds .Unspecified , creds .Unspecified )
540+ assert .ElementsMatch (tt .wantCreds .Password , creds .Password )
450541 })
451542 }
452543}
@@ -507,6 +598,29 @@ func Test_unconsumedSessionCredentials(t *testing.T) {
507598 },
508599 wantCreds : nil ,
509600 },
601+ {
602+ name : "p" ,
603+ creds : Credentials {
604+ Password : []Password {
605+ {
606+ Raw : vaultPassword ,
607+ },
608+ },
609+ },
610+ wantCreds : []* targets.SessionCredential {vaultPassword },
611+ },
612+ {
613+ name : "p-consumed" ,
614+ creds : Credentials {
615+ Password : []Password {
616+ {
617+ Raw : vaultPassword ,
618+ Consumed : true ,
619+ },
620+ },
621+ },
622+ wantCreds : nil ,
623+ },
510624 {
511625 name : "Unspecified" ,
512626 creds : Credentials {
@@ -542,10 +656,23 @@ func Test_unconsumedSessionCredentials(t *testing.T) {
542656 Consumed : true ,
543657 },
544658 },
659+ Password : []Password {
660+ {
661+ Raw : staticPassword ,
662+ },
663+ {
664+ Raw : vaultPassword ,
665+ },
666+ {
667+ Raw : typedPassword ,
668+ Consumed : true ,
669+ },
670+ },
545671 Unspecified : []* targets.SessionCredential {UnspecifiedCred , UnspecifiedCred1 },
546672 },
547673 wantCreds : []* targets.SessionCredential {
548674 vaultSshPrivateKey , typedSshPrivateKey , vaultUsernamePassword , UnspecifiedCred , UnspecifiedCred1 ,
675+ staticPassword , vaultPassword ,
549676 },
550677 },
551678 {
@@ -579,6 +706,20 @@ func Test_unconsumedSessionCredentials(t *testing.T) {
579706 Consumed : true ,
580707 },
581708 },
709+ Password : []Password {
710+ {
711+ Raw : staticPassword ,
712+ Consumed : true ,
713+ },
714+ {
715+ Raw : vaultPassword ,
716+ Consumed : true ,
717+ },
718+ {
719+ Raw : typedPassword ,
720+ Consumed : true ,
721+ },
722+ },
582723 Unspecified : []* targets.SessionCredential {UnspecifiedCred , UnspecifiedCred1 },
583724 },
584725 wantCreds : []* targets.SessionCredential {
@@ -610,11 +751,23 @@ func Test_unconsumedSessionCredentials(t *testing.T) {
610751 Raw : typedUsernamePassword ,
611752 },
612753 },
754+ Password : []Password {
755+ {
756+ Raw : staticPassword ,
757+ },
758+ {
759+ Raw : vaultPassword ,
760+ },
761+ {
762+ Raw : typedPassword ,
763+ },
764+ },
613765 Unspecified : []* targets.SessionCredential {UnspecifiedCred , UnspecifiedCred1 },
614766 },
615767 wantCreds : []* targets.SessionCredential {
616768 staticSshPrivateKey , UnspecifiedCred1 , vaultSshPrivateKey , typedUsernamePassword ,
617769 UnspecifiedCred , vaultUsernamePassword , typedSshPrivateKey , staticUsernamePassword ,
770+ staticPassword , vaultPassword , typedPassword ,
618771 },
619772 },
620773 }
0 commit comments