use serde_json::json;

#[test]
fn secrets_schema_validation_accepts_required_non_empty_keys() {
    let schema_json: serde_json::Value = serde_json::from_str(include_str!("secrets_schema.json")).unwrap();

    let secrets = json!({
        "COIN_GECKO_API": "cg_key_123",
        "PERSONA_API": "persona_key_456"
    });

    newton_prover_core::rego::validate_secrets_schema(schema_json, secrets).unwrap();
}

#[test]
fn secrets_schema_validation_rejects_missing_key() {
    let schema_json: serde_json::Value = serde_json::from_str(include_str!("secrets_schema.json")).unwrap();

    let secrets = json!({
        "COIN_GECKO_API": "cg_key_123"
    });

    assert!(newton_prover_core::rego::validate_secrets_schema(schema_json, secrets).is_err());
}

#[test]
fn secrets_schema_validation_rejects_empty_value() {
    let schema_json: serde_json::Value = serde_json::from_str(include_str!("secrets_schema.json")).unwrap();

    let secrets = json!({
        "COIN_GECKO_API": "",
        "PERSONA_API": "persona_key_456"
    });

    assert!(newton_prover_core::rego::validate_secrets_schema(schema_json, secrets).is_err());
}

#[test]
fn secrets_schema_validation_rejects_additional_keys() {
    let schema_json: serde_json::Value = serde_json::from_str(include_str!("secrets_schema.json")).unwrap();

    let secrets = json!({
        "COIN_GECKO_API": "cg_key_123",
        "PERSONA_API": "persona_key_456",
        "EXTRA": "nope"
    });

    assert!(newton_prover_core::rego::validate_secrets_schema(schema_json, secrets).is_err());
}
