-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add edge test for aws assume role with web identity (#3839)
* refactor: Add edge test for aws assume role with web identity Signed-off-by: Xuanwo <[email protected]> * Make clippy happy Signed-off-by: Xuanwo <[email protected]> * Fix b2 Signed-off-by: Xuanwo <[email protected]> --------- Signed-off-by: Xuanwo <[email protected]>
- Loading branch information
Showing
7 changed files
with
131 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
[package] | ||
edition = "2021" | ||
name = "edge_test_aws_s3_assume_role_with_web_identity" | ||
publish = false | ||
version = "0.0.0" | ||
|
||
license.workspace = true | ||
|
||
[dependencies] | ||
opendal = { workspace = true, features = ["tests"] } | ||
uuid = { version = "1", features = ["serde", "v4"] } | ||
tokio = { version = "1", features = ["full"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# S3 AWS Assume Role With Web Identity | ||
|
||
This edge test case is for AWS s3 services that authed by `Assume Role With Web Identity`. | ||
|
||
For setup, please configure bucket and OIDC correctly, for example: | ||
|
||
```yaml | ||
- uses: actions/github-script@v7 | ||
id: id-token | ||
with: | ||
script: return await core.getIDToken("sts.amazonaws.com") | ||
result-encoding: string | ||
- name: Write ID token to file | ||
run: echo "${{ steps.id-token.outputs.result }}" > core/tests/data/web_identity_token | ||
``` | ||
And configure `AWS_WEB_IDENTITY_TOKEN_FILE` and `AWS_ROLE_ARN`. | ||
|
33 changes: 33 additions & 0 deletions
33
core/edge/s3_aws_assume_role_with_web_identity/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use opendal::raw::tests::init_test_service; | ||
use opendal::{Result, Scheme}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let op = init_test_service()?.expect("service must be init"); | ||
assert_eq!(op.info().scheme(), Scheme::S3); | ||
|
||
let result = op | ||
.is_exist(&uuid::Uuid::new_v4().to_string()) | ||
.await | ||
.expect("this operation should never return error"); | ||
assert!(!result, "the file must be not exist"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters