import ID2TLib.TestLibrary as Lib
import Test.ID2TAttackTest as Test

sha_default = '3063eaf16f7344034e4ecb9b5a0cf6da8e160cb75f268dd3dfd3ad40b7c373a0'
sha_ips_not_in_pcap = '69089b1832b62dfa4bdbc93a47db570e5c88fd78aad06cb440df9be312a4ee93'
sha_multiple_params = '83addb1f0ef39bf74454dd88c14114cd5016f28538450b58ab6b545669427c87'

# TODO: improve coverage


class UnitTestJoomla(Test.ID2TAttackTest):
    def test_joomla_default(self):
        self.checksum_test([['JoomlaRegPrivExploit']], sha_default)

    def test_joomla_ips_not_in_pcap(self):
        self.checksum_test([['JoomlaRegPrivExploit', 'ip.src=1.1.1.1', 'ip.dst=2.2.2.2']], sha_ips_not_in_pcap)

    def test_joomla_multiple_params(self):
        ip_src = 'ip.src=' + Lib.test_pcap_ips[0]
        ip_dst = 'ip.dst=' + Lib.test_pcap_ips[1]
        self.checksum_test([['JoomlaRegPrivExploit', ip_src, ip_dst, 'mac.src=00:0C:21:1C:60:61',
                             'mac.dst=04:0C:32:2C:63:62', 'port.dst=42',
                             'target.host=www.ihopethisisnotarealwebsite.com']], sha_multiple_params)

    def test_joomla_order(self):
        self.order_test([['JoomlaRegPrivExploit']])