---
inputType: "CA10Z1__CaAzureMySqlServer__c"
testData:
  - file: "test-data.json"
importExtracts:
  - file: "/types/CA10Z1__CaAzureMySqlServer__c/object.extracts.yaml"
conditions:
  - status: "INAPPLICABLE"
    currentStateMessage: "This is not the Flexible Server deployment mode."
    check:
      NOT_EQUAL:
        left:
          EXTRACT: "CA10Z1__deploymentMode__c"
        right:
          TEXT: "Flexible"
  - status: "INCOMPLIANT"
    currentStateMessage: "MySQL Flexible Server tls_version configuration parameter is not set to TLSv1.2."
    remediationMessage: "Consider setting MySQL Flexible Server tls_version configuration to TLSv1.2."
    check:
      IS_EQUAL:
        left:
          JSON_QUERY_TEXT:
              arg: 
                EXTRACT: "caJsonFrom__configurations__c"
              expression: "[? name == 'tls_version'].value | [0]"
              undeterminedIf: 
                evaluationError: "The JSON query has failed."
                resultTypeMismatch: "The JSON query did not return text type."
        right:
          TEXT: "TLSv1.0"
  - status: "INCOMPLIANT"
    currentStateMessage: "MySQL Flexible Server tls_version configuration parameter is not set to TLSv1.2."
    remediationMessage: "Consider setting MySQL Flexible Server tls_version configuration to TLSv1.2."
    check:
      IS_EQUAL:
        left:
          JSON_QUERY_TEXT:
              arg: 
                EXTRACT: "caJsonFrom__configurations__c"
              expression: "[? name == 'tls_version'].value | [0]"
              undeterminedIf: 
                evaluationError: "The JSON query has failed."
                resultTypeMismatch: "The JSON query did not return text type."
        right:
          TEXT: "TLSv1.1"
  - status: "COMPLIANT"
    currentStateMessage: "MySQL Flexible Server tls_version configuration parameter is set to TLSv1.2."
    check:
      IS_EQUAL:
        left:
          JSON_QUERY_TEXT:
              arg: 
                EXTRACT: "caJsonFrom__configurations__c"
              expression: "[? name == 'tls_version'].value | [0]"
              undeterminedIf: 
                evaluationError: "The JSON query has failed."
                resultTypeMismatch: "The JSON query did not return text type."
        right:
          TEXT: "TLSv1.2"
  - status: "COMPLIANT"
    currentStateMessage: "MySQL Flexible Server tls_version configuration parameter is set to TLSv1.2."
    check:
      IS_EQUAL:
        left:
          JSON_QUERY_TEXT:
              arg: 
                EXTRACT: "caJsonFrom__configurations__c"
              expression: "[? name == 'tls_version'].value | [0]"
              undeterminedIf: 
                evaluationError: "The JSON query has failed."
                resultTypeMismatch: "The JSON query did not return text type."
        right:
          TEXT: "TLSv1.3"
otherwise:
  status: "UNDETERMINED"
  currentStateMessage: "Unexpected value in the field."