Пример #1
0
def test_query_rule_change_state_to_invalid(current_state, target_state):
    rule = ScannerQueryRule(name='some_rule', scanner=YARA)
    rule.state = current_state
    with pytest.raises(ImproperScannerQueryRuleStateError):
        rule.change_state_to(target_state)
    # Manually changing state doesn't affect 'completed' property, and since
    # changing through change_state_to() failed before it should always be
    # None in this test.
    assert rule.completed is None
Пример #2
0
def test_query_rule_change_state_to_valid(current_state, target_state):
    rule = ScannerQueryRule(name='some_rule', scanner=YARA)
    rule.state = current_state
    with freeze_time('2020-04-08 15:16:23.42') as frozen_time:
        rule.change_state_to(target_state)
    if target_state == COMPLETED:
        assert rule.completed == frozen_time()
    else:
        assert rule.completed is None
Пример #3
0
def test_query_rule_change_state_to_invalid(current_state, target_state):
    rule = ScannerQueryRule(name='some_rule', scanner=YARA)
    rule.state = current_state
    with pytest.raises(ImproperScannerQueryRuleStateError):
        rule.change_state_to(target_state)
Пример #4
0
def test_query_rule_change_state_to_valid(current_state, target_state):
    rule = ScannerQueryRule(name='some_rule', scanner=YARA)
    rule.state = current_state
    rule.change_state_to(target_state)