@@ -136,10 +136,10 @@ export class UserPreferences {
136136 await this . driverHelper . waitVisibility ( UserPreferences . ADD_NEW_SSH_KEY_BUTTON ) ;
137137 }
138138
139- async addSshKeys ( privateSshKeyPath : string , publicSshKeyPath : string ) : Promise < void > {
139+ async addSshKeysFromFiles ( privateSshKeyPath : string , publicSshKeyPath : string ) : Promise < void > {
140140 Logger . debug ( ) ;
141141
142- Logger . info ( 'Adding new SSH keys' ) ;
142+ Logger . info ( 'Adding new SSH keys from files ' ) ;
143143 await this . driverHelper . waitAndClick ( UserPreferences . ADD_NEW_SSH_KEY_BUTTON ) ;
144144 await this . driverHelper . waitVisibility ( UserPreferences . ADD_SSH_KEYS_POPUP ) ;
145145 await this . uploadSshKeys ( privateSshKeyPath , publicSshKeyPath ) ;
@@ -148,6 +148,33 @@ export class UserPreferences {
148148 Logger . info ( 'SSH keys have been added' ) ;
149149 }
150150
151+ async addSshKeysFromStrings ( privateSshKey : string , publicSshKey : string ) : Promise < void > {
152+ Logger . debug ( ) ;
153+
154+ if ( ! privateSshKey || privateSshKey === '' ) {
155+ throw new Error ( 'Private SSH key is empty or not provided' ) ;
156+ }
157+ if ( ! publicSshKey || publicSshKey === '' ) {
158+ throw new Error ( 'Public SSH key is empty or not provided' ) ;
159+ }
160+
161+ Logger . info ( 'Adding new SSH keys from strings' ) ;
162+ await this . driverHelper . waitAndClick ( UserPreferences . ADD_NEW_SSH_KEY_BUTTON ) ;
163+ await this . driverHelper . waitVisibility ( UserPreferences . ADD_SSH_KEYS_POPUP ) ;
164+
165+ Logger . info ( 'Pasting private SSH key' ) ;
166+ await this . driverHelper . waitAndClick ( UserPreferences . PASTE_PRIVATE_SSH_KEY_FIELD ) ;
167+ await this . driverHelper . getAction ( ) . sendKeys ( privateSshKey ) . perform ( ) ;
168+
169+ Logger . info ( 'Pasting public SSH key' ) ;
170+ await this . driverHelper . waitAndClick ( UserPreferences . PASTE_PUBLIC_SSH_KEY_FIELD ) ;
171+ await this . driverHelper . getAction ( ) . sendKeys ( publicSshKey ) . perform ( ) ;
172+
173+ await this . driverHelper . waitAndClick ( UserPreferences . ADD_SSH_KEYS_BUTTON ) ;
174+ await this . driverHelper . waitVisibility ( UserPreferences . GIT_SSH_KEY_NAME ) ;
175+ Logger . info ( 'SSH keys have been added' ) ;
176+ }
177+
151178 async uploadSshKeys ( privateSshKeyPath : string , publicSshKeyPath : string ) : Promise < void > {
152179 Logger . debug ( ) ;
153180 const privateSshKey : string = Buffer . from ( fs . readFileSync ( path . resolve ( privateSshKeyPath ) , 'utf-8' ) , 'base64' ) . toString ( 'utf-8' ) ;
0 commit comments