Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
StatementCondition(ForAllValuesBinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAllValuesBinaryEquals",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(ForAllValuesBinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAllValuesBinaryEquals",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(ForAnyValueBinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAnyValueBinaryEquals",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(ForAnyValueBinaryEqualsIfExists={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAnyValueBinaryEqualsIfExists",
def test_statement_condition_remove_colon():
assert StatementCondition.parse_obj(
{
"ForAllValues:ArnEqualsIfExists": {"patata_1": "test_1"},
"ForAnyValue:ARNEquals": {"patata_2": ["test_2", "test_3"]},
}
) == StatementCondition(
ForAllValuesArnEqualsIfExists={"patata_1": "test_1"}, ForAnyValueARNEquals={"patata_2": ["test_2", "test_3"]}
)
StatementCondition(BinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"BinaryEquals",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(BinaryEqualsIfExists={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"BinaryEqualsIfExists",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(ForAllValuesBinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAllValuesBinaryEquals",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(ForAllValuesBinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAllValuesBinaryEquals",
StatementCondition(BinaryEqualsIfExists={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"BinaryEqualsIfExists",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(ForAllValuesBinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAllValuesBinaryEquals",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(ForAllValuesBinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAllValuesBinaryEquals",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(ForAnyValueBinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAnyValueBinaryEquals",
StatementCondition(ForAnyValueBinaryEqualsIfExists={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAnyValueBinaryEqualsIfExists",
{"key": b"BinaryValueInBase64"},
),
],
)
def test_statement_condition_validate_binary(
statement_condition: StatementCondition, attribute: str, expected_output: bytearray
):
assert getattr(statement_condition, attribute) == expected_output
(StatementCondition(NumericEquals={"patata": 1}), {"patata": 1}, True),
(StatementCondition(NumericEquals={"patata": 1}), {"patata": 2}, False),
(
StatementCondition(NumericEquals={"patata_1": 1}, StringEquals={"patata_2": "A"}),
{"patata_1": 1, "patata_2": "A"},
True,
),
(
StatementCondition(NumericEquals={"patata_1": 1}, StringEquals={"patata_2": "A"}),
{"patata_1": 2, "patata_2": "A"},
False,
),
(
StatementCondition(NumericEquals={"patata_1": 1}, StringEquals={"patata_2": "A"}),
{"patata_1": 1, "patata_2": "B"},
False,
),
StatementCondition(ForAnyValueBinaryEquals={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAnyValueBinaryEquals",
{"key": b"BinaryValueInBase64"},
),
(
StatementCondition(ForAnyValueBinaryEqualsIfExists={"key": "QmluYXJ5VmFsdWVJbkJhc2U2NA=="}),
"ForAnyValueBinaryEqualsIfExists",
{"key": b"BinaryValueInBase64"},
),
],
)
def test_statement_condition_validate_binary(
statement_condition: StatementCondition, attribute: str, expected_output: bytearray
):
assert getattr(statement_condition, attribute) == expected_output
StatementCondition(NumericEquals={"patata_1": 1}, StringEquals={"patata_2": "A"}),
{"patata_1": 1, "patata_2": "A"},
True,
),
(
StatementCondition(NumericEquals={"patata_1": 1}, StringEquals={"patata_2": "A"}),
{"patata_1": 2, "patata_2": "A"},
False,
),
(
StatementCondition(NumericEquals={"patata_1": 1}, StringEquals={"patata_2": "A"}),
{"patata_1": 1, "patata_2": "B"},
False,
),
(
StatementCondition(NumericEquals={"patata_1": 1}, StringEquals={"patata_2": "A"}),
{"patata_1": 2, "patata_2": "B"},
def test_statement_condition_remove_colon():
assert StatementCondition.parse_obj(
{
"ForAllValues:ArnEqualsIfExists": {"patata_1": "test_1"},
"ForAnyValue:ARNEquals": {"patata_2": ["test_2", "test_3"]},
}
) == StatementCondition(
ForAllValuesArnEqualsIfExists={"patata_1": "test_1"}, ForAnyValueARNEquals={"patata_2": ["test_2", "test_3"]}
)