Loading CHANGELOG.next.toml +6 −0 Original line number Diff line number Diff line Loading @@ -110,3 +110,9 @@ message = "Simplify features in aws-config. All features have been removed from references = ["smithy-rs#1017", "smithy-rs#930"] meta = { "breaking" = true, "tada" = false, "bug" = false } author = "rcoh" [[aws-sdk-rust]] message = "Add function to `aws_config::profile::ProfileSet`` that allows listing of loaded profiles by name." references = ["smithy-rs#1021"] meta = { "breaking" = false, "tada" = false, "bug" = false } author = "kiiadi" aws/rust-runtime/aws-config/src/profile/parser.rs +24 −11 Original line number Diff line number Diff line Loading @@ -132,6 +132,11 @@ impl ProfileSet { self.profiles.is_empty() } /// Returns the names of the profiles in this profile set pub fn profiles(&self) -> impl Iterator<Item = &str> { self.profiles.keys().map(String::as_ref) } fn parse(source: Source) -> Result<Self, ProfileParseError> { let mut base = ProfileSet::empty(); base.selected_profile = source.profile; Loading Loading @@ -235,21 +240,29 @@ mod test { #[test] fn empty_source_empty_profile() { let source = Source { config_file: File { path: "~/.aws/config".to_string(), contents: "".into(), }, credentials_file: File { path: "~/.aws/credentials".to_string(), contents: "".into(), }, profile: "default".into(), }; let source = make_source(ParserInput { config_file: Some("".to_string()), credentials_file: Some("".to_string()), }); let profile_set = ProfileSet::parse(source).expect("empty profiles are valid"); assert!(profile_set.is_empty()); } #[test] fn profile_names_are_exposed() { let source = make_source(ParserInput { config_file: Some("[profile foo]\n[profile bar]".to_string()), credentials_file: Some("".to_string()), }); let profile_set = ProfileSet::parse(source).expect("profiles loaded"); let mut profile_names: Vec<_> = profile_set.profiles().collect(); profile_names.sort(); assert_eq!(profile_names, vec!["bar", "foo"]); } /// Run all tests from the fuzzing corpus to validate coverage #[test] #[ignore] Loading Loading
CHANGELOG.next.toml +6 −0 Original line number Diff line number Diff line Loading @@ -110,3 +110,9 @@ message = "Simplify features in aws-config. All features have been removed from references = ["smithy-rs#1017", "smithy-rs#930"] meta = { "breaking" = true, "tada" = false, "bug" = false } author = "rcoh" [[aws-sdk-rust]] message = "Add function to `aws_config::profile::ProfileSet`` that allows listing of loaded profiles by name." references = ["smithy-rs#1021"] meta = { "breaking" = false, "tada" = false, "bug" = false } author = "kiiadi"
aws/rust-runtime/aws-config/src/profile/parser.rs +24 −11 Original line number Diff line number Diff line Loading @@ -132,6 +132,11 @@ impl ProfileSet { self.profiles.is_empty() } /// Returns the names of the profiles in this profile set pub fn profiles(&self) -> impl Iterator<Item = &str> { self.profiles.keys().map(String::as_ref) } fn parse(source: Source) -> Result<Self, ProfileParseError> { let mut base = ProfileSet::empty(); base.selected_profile = source.profile; Loading Loading @@ -235,21 +240,29 @@ mod test { #[test] fn empty_source_empty_profile() { let source = Source { config_file: File { path: "~/.aws/config".to_string(), contents: "".into(), }, credentials_file: File { path: "~/.aws/credentials".to_string(), contents: "".into(), }, profile: "default".into(), }; let source = make_source(ParserInput { config_file: Some("".to_string()), credentials_file: Some("".to_string()), }); let profile_set = ProfileSet::parse(source).expect("empty profiles are valid"); assert!(profile_set.is_empty()); } #[test] fn profile_names_are_exposed() { let source = make_source(ParserInput { config_file: Some("[profile foo]\n[profile bar]".to_string()), credentials_file: Some("".to_string()), }); let profile_set = ProfileSet::parse(source).expect("profiles loaded"); let mut profile_names: Vec<_> = profile_set.profiles().collect(); profile_names.sort(); assert_eq!(profile_names, vec!["bar", "foo"]); } /// Run all tests from the fuzzing corpus to validate coverage #[test] #[ignore] Loading