@@ -348,13 +348,13 @@ R"(
348
348
;another comment
349
349
[ default ]
350
350
source_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
352
352
; Comment to be ignored
353
353
)"
354
354
R"( )" // to avoid blank space removals by an IDE.
355
355
R"(
356
356
[ profile )" " \t\t\t " R"( base ]
357
- region = us-east-1#sa-east-3
357
+ region = us-east-1 #sa-east-3
358
358
#region = commented-out region
359
359
)" ;
360
360
@@ -484,3 +484,101 @@ aws_secret_access_key = correct_secret)";
484
484
ASSERT_EQ (" correct_secret" , profiles.at (complicatedProfileName).GetCredentials ().GetAWSSecretKey ());
485
485
}
486
486
}
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://luminere.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://luminere.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://luminere.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://luminere.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://luminere.com/for-those-who-come-after # stendahl pre nerf)" << " \n "
544
+ << R"( #sso_start_url = https://luminere.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://luminere.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://luminere.com/for-those-who-come-after#when-one-falls-we-continue ; painted power # stendahl pre nerf)" << " \n "
569
+ << R"( ;#sso_start_url = https://luminere.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://luminere.com/for-those-who-come-after#when-one-falls-we-continue" , profile->second .GetSsoStartUrl ().c_str ());
584
+ }
0 commit comments