コード例 #1
0
    def test_colorImageXml(self):
        """
        Test the XML representation of a color image to match the reference.
        """
        sourcePath = 'files/sunflower' + self.ext
        expectedPath = 'files/sunflower.xml'

        message = Message(filePath=sourcePath, messageType='ColorImage')

        with open(self.targetTextFilePath, 'w') as xmlFile:
            xmlString = message.getXmlString()
            xmlFile.write(xmlString)

        actualTextFile, expectedTextFile = loadTwoTextFiles(self.targetTextFilePath, expectedPath)

        self.assertEqual(actualTextFile, expectedTextFile)
コード例 #2
0
    def test_longTextXml(self):
        """
        Test the XML representation of a long text file to match the reference.
        """
        sourcePath = 'files/full.txt'
        expectedPath = 'files/full.xml'

        message = Message(filePath=sourcePath, messageType='Text')

        with open(self.targetTextFilePath, 'w') as xmlFile:
            xmlString = message.getXmlString()
            xmlFile.write(xmlString)

        actualTextFile, expectedTextFile = loadTwoTextFiles(self.targetTextFilePath, expectedPath)

        self.assertEqual(actualTextFile, expectedTextFile)
コード例 #3
0
ファイル: SteganographyTest.py プロジェクト: wang1540/ece364
    def test_colorImageXml(self):
        """
        Test the XML representation of a color image to match the reference.
        """
        sourcePath = 'files/sunflower' + self.ext
        expectedPath = 'files/sunflower.xml'

        message = Message(filePath=sourcePath, messageType='ColorImage')

        with open(self.targetTextFilePath, 'w') as xmlFile:
            xmlString = message.getXmlString()
            xmlFile.write(xmlString)

        actualTextFile, expectedTextFile = loadTwoTextFiles(
            self.targetTextFilePath, expectedPath)

        self.assertEqual(actualTextFile, expectedTextFile)
コード例 #4
0
ファイル: SteganographyTest.py プロジェクト: wang1540/ece364
    def test_longTextXml(self):
        """
        Test the XML representation of a long text file to match the reference.
        """
        sourcePath = 'files/full.txt'
        expectedPath = 'files/full.xml'

        message = Message(filePath=sourcePath, messageType='Text')

        with open(self.targetTextFilePath, 'w') as xmlFile:
            xmlString = message.getXmlString()
            xmlFile.write(xmlString)

        actualTextFile, expectedTextFile = loadTwoTextFiles(
            self.targetTextFilePath, expectedPath)

        self.assertEqual(actualTextFile, expectedTextFile)
コード例 #5
0
    def test_badMessageInitializerWithEmptyPassword(self):
        """
        Test that creating an 'AesMessage' instance with an empty password raises an exception.
        """
        sourcePath = 'files/full.txt'
        message = Message(filePath=sourcePath, messageType='Text')

        self.assertRaises(ValueError, AesMessage, message, password='')
コード例 #6
0
ファイル: SteganographyTest.py プロジェクト: wang1540/ece364
    def test_embedLargeMessageInSmallMedium(self):
        """
        Test that trying to embed a large message in medium, produces an exception.
        """
        sourcePath = 'files/sunflower' + self.ext
        mediumPath = 'files/mona' + self.ext

        message = Message(filePath=sourcePath, messageType='ColorImage')
        medium = Steganography(mediumPath)

        self.assertRaises(ValueError, medium.embedMessageInMedium, message,
                          self.targetImageFilePath)
コード例 #7
0
ファイル: SteganographyTest.py プロジェクト: wang1540/ece364
    def test_embedLongTextHorizontal(self):
        """
        Test the embedding of a long text file in a medium, using a horizontal raster scan.
        """
        sourcePath = 'files/full.txt'
        expectedPath = 'files/lena_full_h' + self.ext
        mediumPath = 'files/lena' + self.ext

        message = Message(filePath=sourcePath, messageType='Text')
        medium = Steganography(mediumPath)
        medium.embedMessageInMedium(message, self.targetImageFilePath)

        actualImage, expectedImage = loadTwoImageFiles(
            self.targetImageFilePath, expectedPath)

        self.assertEqual(actualImage, expectedImage)
コード例 #8
0
ファイル: SteganographyTest.py プロジェクト: wang1540/ece364
    def test_embedShortTextVertical(self):
        """
        Test the embedding of a short text file in a medium, using a vertical raster scan.
        """
        sourcePath = 'files/small.txt'
        expectedPath = 'files/mona_small_v' + self.ext
        mediumPath = 'files/mona' + self.ext

        message = Message(filePath=sourcePath, messageType='Text')
        medium = Steganography(mediumPath, direction='vertical')
        medium.embedMessageInMedium(message, self.targetImageFilePath)

        actualImage, expectedImage = loadTwoImageFiles(
            self.targetImageFilePath, expectedPath)

        self.assertEqual(actualImage, expectedImage)
コード例 #9
0
ファイル: SteganographyTest.py プロジェクト: wang1540/ece364
    def test_embedColorImageVertical(self):
        """
        Test the embedding of a color image in a medium, using a vertical raster scan.
        """
        sourcePath = 'files/sunflower' + self.ext
        expectedPath = 'files/nature_sunflower_v' + self.ext
        mediumPath = 'files/nature' + self.ext

        message = Message(filePath=sourcePath, messageType='ColorImage')
        medium = Steganography(mediumPath, direction='vertical')
        medium.embedMessageInMedium(message, self.targetImageFilePath)

        actualImage, expectedImage = loadTwoImageFiles(
            self.targetImageFilePath, expectedPath)

        self.assertEqual(actualImage, expectedImage)
コード例 #10
0
ファイル: SteganographyTest.py プロジェクト: wang1540/ece364
    def test_embedGrayImageVertical(self):
        """
        Test the embedding of a gray-scale image in a medium, using a vertical raster scan.
        """
        sourcePath = 'files/dog' + self.ext
        expectedPath = 'files/bridge_dog_v' + self.ext
        mediumPath = 'files/bridge' + self.ext

        message = Message(filePath=sourcePath, messageType='GrayImage')
        medium = Steganography(mediumPath, direction='vertical')
        medium.embedMessageInMedium(message, self.targetImageFilePath)

        actualImage, expectedImage = loadTwoImageFiles(
            self.targetImageFilePath, expectedPath)

        self.assertEqual(actualImage, expectedImage)
コード例 #11
0
    def test_embedColorImageHorizontal(self):
        """
        Test the embedding of a color image in a medium, using a horizontal raster scan.
        """
        sourcePath = 'files/sunflower' + self.ext
        expectedPath = 'files/lake_sunflower_h' + self.ext
        mediumPath = 'files/lake' + self.ext

        message = Message(filePath=sourcePath, messageType='ColorImage')
        medium = ColorSteganography(mediumPath)
        medium.embedMessageInMedium(message, self.targetImageFilePath)

        actualImage, expectedImage = loadTwoImageFiles(
            self.targetImageFilePath, expectedPath)

        self.assertEqual(actualImage, expectedImage)
コード例 #12
0
    def test_embedEncryptedColorImage(self):
        """
        Test the embedding of an encrypted color image in a medium.
        """
        sourcePath = 'files/color_mona' + self.ext
        expectedPath = 'files/bridge_color_mona_enc' + self.ext
        mediumPath = 'files/bridge' + self.ext

        message = Message(filePath=sourcePath, messageType='ColorImage')
        encryptedMessage = AesMessage(message, self.password)

        medium = Steganography(mediumPath)
        medium.embedMessageInMedium(encryptedMessage, self.targetImageFilePath)

        actualImage, expectedImage = loadTwoImageFiles(
            self.targetImageFilePath, expectedPath)

        self.assertEqual(actualImage, expectedImage)
コード例 #13
0
    def test_embedEncryptedText(self):
        """
        Test the embedding of an encrypted text file in a medium.
        """
        sourcePath = 'files/full.txt'
        expectedPath = 'files/lena_full_enc' + self.ext
        mediumPath = 'files/lena' + self.ext

        message = Message(filePath=sourcePath, messageType='Text')
        encryptedMessage = AesMessage(message, self.password)

        medium = Steganography(mediumPath)
        medium.embedMessageInMedium(encryptedMessage, self.targetImageFilePath)

        actualImage, expectedImage = loadTwoImageFiles(
            self.targetImageFilePath, expectedPath)

        self.assertEqual(actualImage, expectedImage)
コード例 #14
0
    def test_colorImageXml(self):
        """
        Test the XML representation of an encrypted color image to match the reference.
        """
        sourcePath = 'files/color_mona' + self.ext
        expectedPath = 'files/color_mona_enc.xml'

        message = Message(filePath=sourcePath, messageType='ColorImage')
        encryptedMessage = AesMessage(message, self.password)

        with open(self.targetTextFilePath, 'w') as xmlFile:
            xmlString = encryptedMessage.getXmlString()
            xmlFile.write(xmlString)

        actualTextFile, expectedTextFile = loadTwoTextFiles(
            self.targetTextFilePath, expectedPath)

        self.assertEqual(actualTextFile, expectedTextFile)