Skip to content

Commit 6dbf444

Browse files
committed
test(sandbox): add a signed multimodal native Generative AI live test
Send a GENERIC chat with a base64 PNG image part through the OCI signer so the live suite covers body hashing on a multimodal payload, not only text. Signed-off-by: Federico Kamelhar <federico.kamelhar@oracle.com>
1 parent a4eec2c commit 6dbf444

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

‎crates/openshell-supervisor-network/tests/oci_signature_live.rs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,39 @@ async fn oci_signed_post_generative_ai_native_chat() {
118118
"response should carry a chatResponse: {response}"
119119
);
120120
}
121+
122+
/// A 64x64 solid red PNG, base64-encoded, for the vision request.
123+
const RED_PNG_BASE64: &str = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAS0lEQVR42u3PQQkAAAgAsetfWiP4FgYrsKZeS0BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEDgsqnc8OJg6Ln3AAAAAElFTkSuQmCC";
124+
125+
#[tokio::test]
126+
#[ignore = "requires OCI_TEST_* credentials and network access to OCI"]
127+
async fn oci_signed_post_generative_ai_native_vision() {
128+
let key = signing_key();
129+
let host = format!(
130+
"inference.generativeai.{}.oci.oraclecloud.com",
131+
env("OCI_TEST_REGION")
132+
);
133+
// Multimodal GENERIC chat: the image travels in the body, so this also
134+
// exercises body hashing on a larger payload than the text tests.
135+
let body = format!(
136+
r#"{{"compartmentId":"{}","servingMode":{{"servingType":"ON_DEMAND","modelId":"meta.llama-4-maverick-17b-128e-instruct-fp8"}},"chatRequest":{{"apiFormat":"GENERIC","messages":[{{"role":"USER","content":[{{"type":"TEXT","text":"What color is this image? Answer with one word."}},{{"type":"IMAGE","imageUrl":{{"url":"data:image/png;base64,{}"}}}}]}}],"maxTokens":10}}}}"#,
137+
env("OCI_TEST_COMPARTMENT_ID"),
138+
RED_PNG_BASE64
139+
);
140+
let mut raw = format!(
141+
"POST /20231130/actions/chat HTTP/1.1\r\nHost: {host}\r\nConnection: close\r\nContent-Type: application/json\r\nContent-Length: {}\r\nAccept: application/json\r\n\r\n",
142+
body.len()
143+
)
144+
.into_bytes();
145+
raw.extend_from_slice(body.as_bytes());
146+
let signed = sign_request(&raw, &host, &key).expect("sign vision POST");
147+
let (status, response) = send_tls(&host, &signed).await;
148+
assert_eq!(
149+
status, 200,
150+
"native Generative AI vision chat must accept the proxy signature: {response}"
151+
);
152+
assert!(
153+
response.to_ascii_lowercase().contains("red"),
154+
"model should identify the red image: {response}"
155+
);
156+
}

0 commit comments

Comments
 (0)