diff --git a/aws/rust-runtime/aws-config/src/credential_process.rs b/aws/rust-runtime/aws-config/src/credential_process.rs index e60ce4a241cd4dfc32b4f1099e7f276439b1254d..6aec2a98882929f2bd792f6662ad9db7875cf80a 100644 --- a/aws/rust-runtime/aws-config/src/credential_process.rs +++ b/aws/rust-runtime/aws-config/src/credential_process.rs @@ -231,7 +231,9 @@ mod test { use time::OffsetDateTime; use tokio::time::timeout; + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths #[tokio::test] + #[cfg_attr(windows, ignore)] async fn test_credential_process() { let provider = CredentialProcessProvider::new(String::from( r#"echo '{ "Version": 1, "AccessKeyId": "ASIARTESTID", "SecretAccessKey": "TESTSECRETKEY", "SessionToken": "TESTSESSIONTOKEN", "Expiration": "2022-05-02T18:36:00+00:00" }'"#, @@ -252,7 +254,9 @@ mod test { ); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths #[tokio::test] + #[cfg_attr(windows, ignore)] async fn test_credential_process_no_expiry() { let provider = CredentialProcessProvider::new(String::from( r#"echo '{ "Version": 1, "AccessKeyId": "ASIARTESTID", "SecretAccessKey": "TESTSECRETKEY" }'"#, diff --git a/aws/rust-runtime/aws-config/src/default_provider/credentials.rs b/aws/rust-runtime/aws-config/src/default_provider/credentials.rs index 464b5dcb43f14b4a6941af033f0b1580d4a57917..809a23dfe5074815d5ce39b086aa8bb6805fca66 100644 --- a/aws/rust-runtime/aws-config/src/default_provider/credentials.rs +++ b/aws/rust-runtime/aws-config/src/default_provider/credentials.rs @@ -299,17 +299,21 @@ mod test { make_test!(ecs_credentials_invalid_profile); make_test!(eks_pod_identity_credentials); + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is disabled on Windows because it uses Unix-style paths + #[cfg(not(windows))] make_test!(eks_pod_identity_no_token_file); #[cfg(not(feature = "sso"))] make_test!(sso_assume_role #[should_panic(expected = "This behavior requires following cargo feature(s) enabled: sso")]); - #[cfg(not(feature = "sso"))] - make_test!(sso_no_token_file #[should_panic(expected = "This behavior requires following cargo feature(s) enabled: sso")]); #[cfg(feature = "sso")] make_test!(sso_assume_role); - #[cfg(feature = "sso")] + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is disabled on Windows because it uses Unix-style paths + #[cfg(not(any(feature = "sso", windows)))] + make_test!(sso_no_token_file #[should_panic(expected = "This behavior requires following cargo feature(s) enabled: sso")]); + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is disabled on Windows because it uses Unix-style paths + #[cfg(all(feature = "sso", not(windows)))] make_test!(sso_no_token_file); #[cfg(feature = "credentials-sso")] diff --git a/aws/rust-runtime/aws-config/src/imds/client.rs b/aws/rust-runtime/aws-config/src/imds/client.rs index a660369c5c32e0e782e7daa14d44706641671a07..7bdc14f2a75585c229a6d7f76cdb22d1539b6f57 100644 --- a/aws/rust-runtime/aws-config/src/imds/client.rs +++ b/aws/rust-runtime/aws-config/src/imds/client.rs @@ -982,6 +982,8 @@ pub(crate) mod test { http_client.assert_requests_match(&[]); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] /// Verify that the end-to-end real client has a 1-second connect timeout #[tokio::test] #[cfg(feature = "rustls")] diff --git a/aws/rust-runtime/aws-config/src/imds/credentials.rs b/aws/rust-runtime/aws-config/src/imds/credentials.rs index 896e66d6df2b78388cbf1fda8bde6a1fab8e3be2..888237d1a348456995d23961bfb3b7402658d20e 100644 --- a/aws/rust-runtime/aws-config/src/imds/credentials.rs +++ b/aws/rust-runtime/aws-config/src/imds/credentials.rs @@ -454,6 +454,8 @@ mod test { ); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] #[tokio::test] #[cfg(feature = "rustls")] async fn external_timeout_during_credentials_refresh_should_yield_last_retrieved_credentials() { diff --git a/aws/rust-runtime/aws-config/src/profile/credentials.rs b/aws/rust-runtime/aws-config/src/profile/credentials.rs index 47478a4c427d4b2602b213b80d0ac7182efa8aa2..9d8b4255b091d179864e5b00093acd13b2bec476 100644 --- a/aws/rust-runtime/aws-config/src/profile/credentials.rs +++ b/aws/rust-runtime/aws-config/src/profile/credentials.rs @@ -594,9 +594,11 @@ mod test { make_test!(retry_on_error); make_test!(invalid_config); make_test!(region_override); - #[cfg(feature = "credentials-process")] + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is disabled on Windows because it uses Unix-style paths + #[cfg(all(feature = "credentials-process", not(windows)))] make_test!(credential_process); - #[cfg(feature = "credentials-process")] + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is disabled on Windows because it uses Unix-style paths + #[cfg(all(feature = "credentials-process", not(windows)))] make_test!(credential_process_failure); #[cfg(feature = "credentials-process")] make_test!(credential_process_invalid); @@ -622,6 +624,8 @@ mod sso_tests { use aws_types::os_shim_internal::{Env, Fs}; use std::collections::HashMap; + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] // In order to preserve the SSO token cache, the inner provider must only // be created once, rather than once per credential resolution. #[tokio::test] diff --git a/aws/rust-runtime/aws-config/src/profile/parser/source.rs b/aws/rust-runtime/aws-config/src/profile/parser/source.rs index dc47c9b9977e8711e1ce622bf6c6f131f550c2aa..26dc4e1298d9566950d7a4af2f1d73852b3feb21 100644 --- a/aws/rust-runtime/aws-config/src/profile/parser/source.rs +++ b/aws/rust-runtime/aws-config/src/profile/parser/source.rs @@ -413,7 +413,9 @@ mod tests { assert_eq!(contents, source.files[0].contents); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths #[tokio::test] + #[cfg_attr(windows, ignore)] async fn programmatically_include_default_files() { let config_contents = "[default]\nregion = us-east-1"; let credentials_contents = "[default]\n\ diff --git a/aws/rust-runtime/aws-config/src/sso/cache.rs b/aws/rust-runtime/aws-config/src/sso/cache.rs index 5d78798f87d9d22298c35aaec5462c3ff3325c54..3955d1b3aa75ede112689fdb6a2fa1aed44d6131 100644 --- a/aws/rust-runtime/aws-config/src/sso/cache.rs +++ b/aws/rust-runtime/aws-config/src/sso/cache.rs @@ -514,6 +514,8 @@ mod tests { ); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] #[test] fn determine_correct_cache_filenames() { assert_eq!( @@ -534,6 +536,8 @@ mod tests { ); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] #[tokio::test] async fn save_cached_token() { let expires_at = SystemTime::UNIX_EPOCH + Duration::from_secs(50_000_000); diff --git a/aws/rust-runtime/aws-config/src/sso/token.rs b/aws/rust-runtime/aws-config/src/sso/token.rs index 98b2b28f5f6633ddff3d788fce6a397f3922c57c..0cf6f0572e0e7e7103111fe053c080ec97ce0c29 100644 --- a/aws/rust-runtime/aws-config/src/sso/token.rs +++ b/aws/rust-runtime/aws-config/src/sso/token.rs @@ -513,6 +513,8 @@ mod tests { } } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] #[tokio::test] async fn use_unexpired_cached_token() { let fs = Fs::from_slice(&[( @@ -536,6 +538,8 @@ mod tests { req_rx.expect_no_request(); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] #[tokio::test] async fn expired_cached_token() { let fs = Fs::from_slice(&[( @@ -557,6 +561,8 @@ mod tests { req_rx.expect_no_request(); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] #[tokio::test] async fn expired_token_and_expired_client_registration() { let fs = Fs::from_slice(&[( @@ -584,6 +590,8 @@ mod tests { req_rx.expect_no_request(); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] #[tokio::test] async fn expired_token_refresh_with_refresh_token() { let fs = Fs::from_slice(&[( @@ -666,6 +674,8 @@ mod tests { ); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] #[tokio::test] async fn expired_token_refresh_fails() { let fs = Fs::from_slice(&[( @@ -705,6 +715,8 @@ mod tests { let _ = req_rx.expect_request(); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] // Expired token refresh without new refresh token #[tokio::test] async fn expired_token_refresh_without_new_refresh_token() { @@ -755,6 +767,8 @@ mod tests { let _ = req_rx.expect_request(); } + // TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths + #[cfg_attr(windows, ignore)] #[tokio::test] async fn refresh_timings() { let _logs = capture_test_logs(); diff --git a/aws/sdk/build.gradle.kts b/aws/sdk/build.gradle.kts index 6d293dd92a4495b771d1f08c3e401af45ba601d3..bcc25bbe49ca565f79fb6aed65463ce3bda2171f 100644 --- a/aws/sdk/build.gradle.kts +++ b/aws/sdk/build.gradle.kts @@ -87,6 +87,9 @@ fun generateSmithyBuild(services: AwsServices): String { } val moduleName = "aws-sdk-${service.module}" val eventStreamAllowListMembers = eventStreamAllowList.joinToString(", ") { "\"$it\"" } + val defaultConfigPath = services.defaultConfigPath.let { software.amazon.smithy.utils.StringUtils.escapeJavaString(it, "") } + val partitionsConfigPath = services.partitionsConfigPath.let { software.amazon.smithy.utils.StringUtils.escapeJavaString(it, "") } + val integrationTestPath = project.projectDir.resolve("integration-tests").let { software.amazon.smithy.utils.StringUtils.escapeJavaString(it, "") } """ "${service.module}": { "imports": [${files.joinToString()}], @@ -117,9 +120,9 @@ fun generateSmithyBuild(services: AwsServices): String { "awsSdk": { "awsSdkBuild": true, "awsConfigVersion": "$awsConfigVersion", - "defaultConfigPath": "${services.defaultConfigPath}", - "partitionsConfigPath": "${services.partitionsConfigPath}", - "integrationTestPath": "${project.projectDir.resolve("integration-tests")}" + "defaultConfigPath": $defaultConfigPath, + "partitionsConfigPath": $partitionsConfigPath, + "integrationTestPath": $integrationTestPath } } ${service.extraConfig ?: ""} diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt index 8481cfadb54ec2b29df09d5c389bf28f5a3120fd..7034ed1f12acc985aedef5eb0cbb261f930eaeac 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt @@ -624,7 +624,11 @@ class RustWriter private constructor( init { expressionStart = '#' if (filename.endsWith(".rs")) { - require(namespace.startsWith("crate") || filename.startsWith("tests/") || filename == "build.rs") { + require( + namespace.startsWith("crate") || + filename.startsWith("tests${File.separator}") || + filename == "build.rs", + ) { "We can only write into files in the crate (got $namespace)" } } diff --git a/tools/ci-build/crate-hasher/src/file_list.rs b/tools/ci-build/crate-hasher/src/file_list.rs index 698caca2b80790c0087f416a6e207a6c87f3a229..4d9c818194670c2c9a8bead5295721f3bbdd4d92 100644 --- a/tools/ci-build/crate-hasher/src/file_list.rs +++ b/tools/ci-build/crate-hasher/src/file_list.rs @@ -3,13 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +use anyhow::{Context, Result}; use std::collections::BTreeSet; use std::fmt::Write; use std::fs::Metadata; use std::path::Path; -use anyhow::{Context, Result}; - #[derive(Debug, Default)] pub struct FileList(BTreeSet); @@ -95,16 +94,30 @@ impl FileMetadata { } } -/// Returns the file mode (permissions) for the given path +/// Returns the file mode (permissions) for the given path. +/// +/// On Windows, this returns the file attributes instead of the permissions. fn file_mode(path: &Path, metadata: &Metadata) -> Result { - use std::os::unix::fs::PermissionsExt; - - if metadata.file_type().is_symlink() { - let actual_path = std::fs::read_link(path).context("follow symlink")?; - let actual_metadata = std::fs::metadata(&actual_path).context("file metadata")?; - file_mode(&actual_path, &actual_metadata) - } else { - Ok(metadata.permissions().mode()) + #[cfg(windows)] + { + use std::os::windows::fs::MetadataExt; + let _ = path; // Unused on Windows + + // Not actually equivalent to a unix permission, but good enough to be hashed. + Ok(metadata.file_attributes()) + } + + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + + if metadata.file_type().is_symlink() { + let actual_path = std::fs::read_link(path).context("follow symlink")?; + let actual_metadata = std::fs::metadata(&actual_path).context("file metadata")?; + file_mode(&actual_path, &actual_metadata) + } else { + Ok(metadata.permissions().mode()) + } } } diff --git a/tools/ci-scripts/test-windows.sh b/tools/ci-scripts/test-windows.sh index 1c1b8a142dab986b386b70630030dd96475eb1ea..8a260bc95d4127dedc6f4d48287e2d646dbed42c 100755 --- a/tools/ci-scripts/test-windows.sh +++ b/tools/ci-scripts/test-windows.sh @@ -16,4 +16,6 @@ for runtime_path in "rust-runtime" "aws/rust-runtime"; do cargo doc --no-deps --document-private-items --all-features --workspace "${exclusions[@]}" popd &>/dev/null done +# TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) We don't have a way to codegen the deps needed by the aws-config crate +# (cd aws/rust-runtime/aws-config && cargo test --all-features) # aws-config is not part of the workspace so we have to test it separately (cd rust-runtime && cargo test -p aws-smithy-experimental --features crypto-ring) # only ring works on windows