@@ -339,6 +339,56 @@ func TestRunLogin(t *testing.T) {
339339 },
340340 },
341341 },
342+ {
343+ doc : "password with leading and trailing spaces" ,
344+ priorCredentials : map [string ]configtypes.AuthConfig {},
345+ input : loginOptions {
346+ serverAddress : "reg1" ,
347+ user : "my-username" ,
348+ password : " my password with spaces " ,
349+ },
350+ expectedCredentials : map [string ]configtypes.AuthConfig {
351+ "reg1" : {
352+ Username : "my-username" ,
353+ Password : " my password with spaces " ,
354+ ServerAddress : "reg1" ,
355+ },
356+ },
357+ },
358+ {
359+ doc : "password stdin with line-endings" ,
360+ priorCredentials : map [string ]configtypes.AuthConfig {},
361+ stdIn : " my password with spaces \r \n " ,
362+ input : loginOptions {
363+ serverAddress : "reg1" ,
364+ user : "my-username" ,
365+ passwordStdin : true ,
366+ },
367+ expectedCredentials : map [string ]configtypes.AuthConfig {
368+ "reg1" : {
369+ Username : "my-username" ,
370+ Password : " my password with spaces " ,
371+ ServerAddress : "reg1" ,
372+ },
373+ },
374+ },
375+ {
376+ doc : "password stdin with multiple line-endings" ,
377+ priorCredentials : map [string ]configtypes.AuthConfig {},
378+ stdIn : " my password\n with spaces \r \n \r \n " ,
379+ input : loginOptions {
380+ serverAddress : "reg1" ,
381+ user : "my-username" ,
382+ passwordStdin : true ,
383+ },
384+ expectedCredentials : map [string ]configtypes.AuthConfig {
385+ "reg1" : {
386+ Username : "my-username" ,
387+ Password : " my password\n with spaces \r \n " ,
388+ ServerAddress : "reg1" ,
389+ },
390+ },
391+ },
342392 }
343393
344394 for _ , tc := range testCases {
0 commit comments