Skip to content

Commit c34cff6

Browse files
fmt
1 parent c6d092e commit c34cff6

File tree

3 files changed

+48
-34
lines changed

3 files changed

+48
-34
lines changed

lambda-integration-tests/src/tenant_id_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use serde_json::{json, Value};
33

44
async fn function_handler(event: LambdaEvent<Value>) -> Result<Value, Error> {
55
let (event, context) = event.into_parts();
6-
6+
77
tracing::info!("Processing request with tenant ID: {:?}", context.tenant_id);
8-
8+
99
let response = json!({
1010
"statusCode": 200,
1111
"body": json!({

lambda-integration-tests/tests/tenant_id_prod_test.rs

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,56 @@ use serde_json::json;
22

33
#[test]
44
fn test_tenant_id_functionality_in_production() {
5-
let function_name = std::env::var("TENANT_ID_TEST_FUNCTION")
6-
.expect("TENANT_ID_TEST_FUNCTION environment variable not set");
7-
5+
let function_name =
6+
std::env::var("TENANT_ID_TEST_FUNCTION").expect("TENANT_ID_TEST_FUNCTION environment variable not set");
7+
88
// Test with tenant ID
99
let payload_with_tenant = json!({
1010
"test": "tenant_id_test",
1111
"message": "Testing with tenant ID"
1212
});
13-
13+
1414
let output = std::process::Command::new("aws")
1515
.args([
16-
"lambda", "invoke",
17-
"--function-name", &function_name,
18-
"--payload", &payload_with_tenant.to_string(),
19-
"--cli-binary-format", "raw-in-base64-out",
20-
"/tmp/tenant_response.json"
16+
"lambda",
17+
"invoke",
18+
"--function-name",
19+
&function_name,
20+
"--payload",
21+
&payload_with_tenant.to_string(),
22+
"--cli-binary-format",
23+
"raw-in-base64-out",
24+
"/tmp/tenant_response.json",
2125
])
2226
.output()
2327
.expect("Failed to invoke Lambda function");
24-
25-
assert!(output.status.success(), "Lambda invocation failed: {}",
26-
String::from_utf8_lossy(&output.stderr));
27-
28+
29+
assert!(
30+
output.status.success(),
31+
"Lambda invocation failed: {}",
32+
String::from_utf8_lossy(&output.stderr)
33+
);
34+
2835
// Read and verify response
29-
let response = std::fs::read_to_string("/tmp/tenant_response.json")
30-
.expect("Failed to read response file");
31-
32-
let response_json: serde_json::Value = serde_json::from_str(&response)
33-
.expect("Failed to parse response JSON");
34-
36+
let response = std::fs::read_to_string("/tmp/tenant_response.json").expect("Failed to read response file");
37+
38+
let response_json: serde_json::Value = serde_json::from_str(&response).expect("Failed to parse response JSON");
39+
3540
// Verify the function executed successfully
3641
assert_eq!(response_json["statusCode"], 200);
37-
42+
3843
// Parse the body to check tenant_id field exists (even if null)
39-
let body: serde_json::Value = serde_json::from_str(
40-
response_json["body"].as_str().expect("Body should be a string")
41-
).expect("Failed to parse body JSON");
42-
43-
assert!(body.get("tenant_id").is_some(), "tenant_id field should be present in response");
44+
let body: serde_json::Value =
45+
serde_json::from_str(response_json["body"].as_str().expect("Body should be a string"))
46+
.expect("Failed to parse body JSON");
47+
48+
assert!(
49+
body.get("tenant_id").is_some(),
50+
"tenant_id field should be present in response"
51+
);
4452
assert!(body.get("request_id").is_some(), "request_id should be present");
4553
assert_eq!(body["message"], "Tenant ID test successful");
46-
54+
4755
println!("✅ Tenant ID production test passed");
4856
println!("Response: {}", serde_json::to_string_pretty(&response_json).unwrap());
4957
}

lambda-runtime/tests/tenant_id_integration.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use lambda_runtime::Context;
21
use http::HeaderMap;
2+
use lambda_runtime::Context;
33
use std::sync::Arc;
44

55
#[test]
66
fn test_context_tenant_id_extraction() {
77
let config = Arc::new(lambda_runtime::Config::default());
8-
8+
99
// Test with tenant ID
1010
let mut headers = HeaderMap::new();
1111
headers.insert("lambda-runtime-aws-request-id", "test-id".parse().unwrap());
@@ -27,21 +27,27 @@ fn test_context_tenant_id_extraction() {
2727
#[test]
2828
fn test_context_tenant_id_with_special_characters() {
2929
let config = Arc::new(lambda_runtime::Config::default());
30-
30+
3131
// Test with tenant ID containing special characters
3232
let mut headers = HeaderMap::new();
3333
headers.insert("lambda-runtime-aws-request-id", "test-id".parse().unwrap());
3434
headers.insert("lambda-runtime-deadline-ms", "123456789".parse().unwrap());
35-
headers.insert("lambda-runtime-aws-tenant-id", "tenant-with-dashes_and_underscores.123".parse().unwrap());
35+
headers.insert(
36+
"lambda-runtime-aws-tenant-id",
37+
"tenant-with-dashes_and_underscores.123".parse().unwrap(),
38+
);
3639

3740
let context = Context::new("test-id", config, &headers).unwrap();
38-
assert_eq!(context.tenant_id, Some("tenant-with-dashes_and_underscores.123".to_string()));
41+
assert_eq!(
42+
context.tenant_id,
43+
Some("tenant-with-dashes_and_underscores.123".to_string())
44+
);
3945
}
4046

4147
#[test]
4248
fn test_context_tenant_id_empty_value() {
4349
let config = Arc::new(lambda_runtime::Config::default());
44-
50+
4551
// Test with empty tenant ID
4652
let mut headers = HeaderMap::new();
4753
headers.insert("lambda-runtime-aws-request-id", "test-id".parse().unwrap());

0 commit comments

Comments
 (0)