fn test_sign_case3()

in sign/src/sign.rs [333:376]


    fn test_sign_case3() {
        init();

        let mut headers = HeaderMap::new();
        headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
        let body = r#"
            {"key": "value"}
        "#;

        let signature = sign_v1(
            "test-access-key-id",
            "test-access-key",
            Some("test-security-token"),
            Method::POST,
            "/logstores/test-logstore",
            &mut headers,
            [("type", "log"), ("offset", "0"), ("line", "100")].into(),
            Some(body.as_bytes()),
        )
        .unwrap();
        assert_eq!(
            signature,
            "LOG test-access-key-id:ZQt+0wIvpd+O9yIJKeKxZTJ2hv0="
        );
        assert!(headers.contains_key(LOG_AUTHORIZATION));
        assert!(headers.contains_key(DATE));
        assert!(headers.contains_key(LOG_API_VERSION));
        assert!(headers.contains_key(LOG_SIGNATURE_METHOD));
        assert!(headers.contains_key(CONTENT_LENGTH));
        assert!(headers.contains_key(LOG_CONTENT_MD5));
        assert!(headers.contains_key(LOG_ACS_SECURITY_TOKEN));
        assert_eq!(
            "CE688F8D1AC3ED309BA9BE0A5ABAFCE5",
            headers.get(LOG_CONTENT_MD5).unwrap().to_str().unwrap()
        );
        assert_eq!(
            "test-security-token",
            headers
                .get(LOG_ACS_SECURITY_TOKEN)
                .unwrap()
                .to_str()
                .unwrap()
        );
    }