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)
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)
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)
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)
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='')
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)
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)
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)
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)
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)
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)
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)
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)
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)