Example #1
0
    def test_get_recommend(cls):
        var = Variable('RHOST')
        var.set({'func': 'recommend', 'value': '192.168.1.1'})
        var.set({'func': 'recommend', 'value': '192.168.1.2'})
        # TODO 还要增加 recommend_cmd

        recommend = var.get_recommend()
        assert len(recommend) == 2
        assert recommend == ['192.168.1.1', '192.168.1.2']
Example #2
0
    def test_merge(cls):
        var = Variable('RHOST')
        var.set({'func': 'desc', 'value': 'remote host'})
        var.set({'func': 'recommend', 'value': '192.168.1.1'})
        var.set({'func': 'recommend', 'value': '192.168.1.2'})

        other_var = Variable('RHOST')
        other_var.set({'func': 'desc', 'value': 'rhost'})
        other_var.set({'func': 'recommend', 'value': '10.10.10.1'})

        var.merge(other_var)

        assert var.desc == 'remote host'
        assert len(var.recommend) == 3
        assert var.recommend[2] == '10.10.10.1'
Example #3
0
    def test_set(cls):
        var = Variable('RHOST')
        var.set({'func': 'desc', 'value': 'remote host'})
        assert var.desc == 'remote host'

        var.set({'func': 'recommend', 'value': '192.168.1.1'})
        assert var.recommend[0] == '192.168.1.1'
        var.set({'func': 'recommend', 'value': '192.168.1.2'})
        assert var.recommend[1] == '192.168.1.2'

        var.set({'func': 'recommend_cmd', 'value': '-r'})
        assert var.recommend_cmd[0] == '-r'
        var.set({'func': 'recommend_cmd', 'value': '-d'})
        assert var.recommend_cmd[1] == '-d'

        var.set({'func': 'if_has', 'value': '-r %s'})
        assert var.if_has == '-r %s'

        var.set({'func': 'refresh'})
        assert len(var.recommend) == 0
        assert len(var.recommend_cmd) == 0