@@ -348,13 +348,13 @@ R"(
348348 ;another comment
349349[ default ]
350350source_profile = base)" " \t " R"(
351- credential_process = echo '{ "Version": 1, "AccessKeyId": "ASIARTESTID", "SecretAccessKey": "TESTSECRETKEY", "SessionToken": "TESTSESSIONTOKEN", "Expiration": "2022-05-02T18:36:00+00:00" }'#COMMENT
351+ credential_process = echo '{ "Version": 1, "AccessKeyId": "ASIARTESTID", "SecretAccessKey": "TESTSECRETKEY", "SessionToken": "TESTSESSIONTOKEN", "Expiration": "2022-05-02T18:36:00+00:00" }' #COMMENT
352352 ; Comment to be ignored
353353)"
354354R"( )" // to avoid blank space removals by an IDE.
355355R"(
356356[ profile )" " \t\t\t " R"( base ]
357- region = us-east-1#sa-east-3
357+ region = us-east-1 #sa-east-3
358358 #region = commented-out region
359359)" ;
360360
@@ -484,3 +484,126 @@ aws_secret_access_key = correct_secret)";
484484 ASSERT_EQ (" correct_secret" , profiles.at (complicatedProfileName).GetCredentials ().GetAWSSecretKey ());
485485 }
486486}
487+
488+ TEST_F (AWSConfigFileProfileConfigLoaderTest, TestSsoStartUrlWithHash) {
489+ TempFile configFile (std::ios_base::out | std::ios_base::trunc);
490+ ASSERT_TRUE (configFile.good ());
491+
492+ configFile << R"( [profile gustave])" << " \n "
493+ << R"( sso_account_id = 333333333333)" << " \n "
494+ << R"( sso_role_name = PictoAccess)" << " \n "
495+ << R"( sso_start_url = https://lumiere.com/for-those-who-come-after#)" << " \n "
496+ << R"( sso_region = eu-west-3)" << " \n "
497+ << R"( sso_registration_scopes = sso:account:access)" << " \n "
498+ << R"( region = eu-west-3)" << " \n "
499+ << R"( output = json)" << " \n " ;
500+
501+ configFile.flush ();
502+
503+ AWSConfigFileProfileConfigLoader loader (configFile.GetFileName (), true );
504+ ASSERT_TRUE (loader.Load ());
505+ const auto & loadedProfiles = loader.GetProfiles ();
506+ ASSERT_TRUE (loadedProfiles.size () == 1 );
507+ const auto & profile = loadedProfiles.find (" gustave" );
508+ ASSERT_TRUE (profile != loadedProfiles.end ());
509+ ASSERT_STREQ (" https://lumiere.com/for-those-who-come-after#" , profile->second .GetSsoStartUrl ().c_str ());
510+ }
511+
512+ TEST_F (AWSConfigFileProfileConfigLoaderTest, TestSsoStartUrlWithComment) {
513+ TempFile configFile (std::ios_base::out | std::ios_base::trunc);
514+ ASSERT_TRUE (configFile.good ());
515+
516+ configFile << R"( [profile lune])" << " \n "
517+ << R"( sso_account_id = 333333333333)" << " \n "
518+ << R"( sso_role_name = PictoAccess)" << " \n "
519+ << R"( sso_start_url = https://lumiere.com/for-those-who-come-after # stained)" << " \n "
520+ << R"( sso_region = eu-west-3)" << " \n "
521+ << R"( sso_registration_scopes = sso:account:access)" << " \n "
522+ << R"( region = eu-west-3)" << " \n "
523+ << R"( output = json)" << " \n " ;
524+
525+ configFile.flush ();
526+
527+ AWSConfigFileProfileConfigLoader loader (configFile.GetFileName (), true );
528+ ASSERT_TRUE (loader.Load ());
529+ const auto & loadedProfiles = loader.GetProfiles ();
530+ ASSERT_TRUE (loadedProfiles.size () == 1 );
531+ const auto & profile = loadedProfiles.find (" lune" );
532+ ASSERT_TRUE (profile != loadedProfiles.end ());
533+ ASSERT_STREQ (" https://lumiere.com/for-those-who-come-after" , profile->second .GetSsoStartUrl ().c_str ());
534+ }
535+
536+ TEST_F (AWSConfigFileProfileConfigLoaderTest, TestSsoStartUrlLineCommnent) {
537+ TempFile configFile (std::ios_base::out | std::ios_base::trunc);
538+ ASSERT_TRUE (configFile.good ());
539+
540+ configFile << R"( [profile maelle])" << " \n "
541+ << R"( sso_account_id = 333333333333)" << " \n "
542+ << R"( sso_role_name = PictoAccess)" << " \n "
543+ << R"( sso_start_url = https://lumiere.com/for-those-who-come-after # stendahl pre nerf)" << " \n "
544+ << R"( #sso_start_url = https://lumiere.com/verso)" << " \n "
545+ << R"( sso_region = eu-west-3)" << " \n "
546+ << R"( sso_registration_scopes = sso:account:access)" << " \n "
547+ << R"( region = eu-west-3)" << " \n "
548+ << R"( output = json)" << " \n " ;
549+
550+ configFile.flush ();
551+
552+ AWSConfigFileProfileConfigLoader loader (configFile.GetFileName (), true );
553+ ASSERT_TRUE (loader.Load ());
554+ const auto & loadedProfiles = loader.GetProfiles ();
555+ ASSERT_TRUE (loadedProfiles.size () == 1 );
556+ const auto & profile = loadedProfiles.find (" maelle" );
557+ ASSERT_TRUE (profile != loadedProfiles.end ());
558+ ASSERT_STREQ (" https://lumiere.com/for-those-who-come-after" , profile->second .GetSsoStartUrl ().c_str ());
559+ }
560+
561+ TEST_F (AWSConfigFileProfileConfigLoaderTest, TestSsoStartUrlShouldHandleMultipleCommentsCorrectly) {
562+ TempFile configFile (std::ios_base::out | std::ios_base::trunc);
563+ ASSERT_TRUE (configFile.good ());
564+
565+ configFile << R"( [profile maelle])" << " \n "
566+ << R"( sso_account_id = 333333333333)" << " \n "
567+ << R"( sso_role_name = PictoAccess)" << " \n "
568+ << R"( sso_start_url = https://lumiere.com/for-those-who-come-after#when-one-falls-we-continue ; painted power # stendahl pre nerf)" << " \n "
569+ << R"( ;#sso_start_url = https://lumiere.com/verso)" << " \n "
570+ << R"( sso_region = eu-west-3)" << " \n "
571+ << R"( sso_registration_scopes = sso:account:access)" << " \n "
572+ << R"( region = eu-west-3)" << " \n "
573+ << R"( output = json)" << " \n " ;
574+
575+ configFile.flush ();
576+
577+ AWSConfigFileProfileConfigLoader loader (configFile.GetFileName (), true );
578+ ASSERT_TRUE (loader.Load ());
579+ const auto & loadedProfiles = loader.GetProfiles ();
580+ ASSERT_TRUE (loadedProfiles.size () == 1 );
581+ const auto & profile = loadedProfiles.find (" maelle" );
582+ ASSERT_TRUE (profile != loadedProfiles.end ());
583+ ASSERT_STREQ (" https://lumiere.com/for-those-who-come-after#when-one-falls-we-continue" , profile->second .GetSsoStartUrl ().c_str ());
584+ }
585+
586+ TEST_F (AWSConfigFileProfileConfigLoaderTest, TestSsoStartUrlShouldHandleTabbedCommentsCorrectly) {
587+ TempFile configFile (std::ios_base::out | std::ios_base::trunc);
588+ ASSERT_TRUE (configFile.good ());
589+
590+ configFile << R"( [profile maelle])" << " \n "
591+ << R"( sso_account_id = 333333333333)" << " \n "
592+ << R"( sso_role_name = PictoAccess)" << " \n "
593+ << R"( sso_start_url = https://lumiere.com/for-those-who-come-after#when-one-falls-we-continue)" << " \t " << R"( #tabbed comment)" << " \n "
594+ << R"( ;#sso_start_url = https://lumiere.com/verso)" << " \n "
595+ << R"( sso_region = eu-west-3)" << " \n "
596+ << R"( sso_registration_scopes = sso:account:access)" << " \n "
597+ << R"( region = eu-west-3)" << " \n "
598+ << R"( output = json)" << " \n " ;
599+
600+ configFile.flush ();
601+
602+ AWSConfigFileProfileConfigLoader loader (configFile.GetFileName (), true );
603+ ASSERT_TRUE (loader.Load ());
604+ const auto & loadedProfiles = loader.GetProfiles ();
605+ ASSERT_TRUE (loadedProfiles.size () == 1 );
606+ const auto & profile = loadedProfiles.find (" maelle" );
607+ ASSERT_TRUE (profile != loadedProfiles.end ());
608+ ASSERT_STREQ (" https://lumiere.com/for-those-who-come-after#when-one-falls-we-continue" , profile->second .GetSsoStartUrl ().c_str ());
609+ }
0 commit comments