Jacques M. Bahi

184 papers A 9B 8C 16Misc 1Journal 106Unranked 43
YearRankTypeTitle / Venue / Authors
2023 conf
ICONIP (8)
Jacques M. Bahi, Raphaël Couturier, Joseph Azar, Kevin Kana Nguimfack
2023 J jnl
J. Supercomput.
Christophe Guyeux, Gaby Bou Tayeh, Abdallah Makhoul, Stéphane Chrétien, Julien Bourgeois, Jacques M. Bahi
2022 conf
IntelliSys (1)
Christophe Guyeux, Abdallah Makhoul, Jacques M. Bahi
2022 conf
WorldCIST (1)
Christophe Guyeux, Jacques M. Bahi
2021 B conf
IWCMC
Gaby Bou Tayeh, Christophe Guyeux, Abdallah Makhoul, Jacques M. Bahi, Sébastien Freidig
2020 J jnl
World Wide Web
Gaby Bou Tayeh, Abdallah Makhoul, Jacques Demerjian, Christophe Guyeux, Jacques M. Bahi
2019 J jnl
J. Sens. Actuator Networks
Christophe Guyeux, Stéphane Chrétien, Gaby Bou Tayeh, Jacques Demerjian, Jacques M. Bahi
2019 J jnl
Comput. Ind.
Jacques M. Bahi, Wiem Elghazel, Christophe Guyeux, Mourad Hakem, Kamal Medjaher, Noureddine Zerhouni
2018 conf
MENACOMM
Luigi Marangio, Christophe Guyeux, Jacques M. Bahi
2017 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux, Pierre-Cyrille Héam
2017 J jnl
CoRR
Jacques M. Bahi, Jean-François Couchot, Nicolas Friot, Christophe Guyeux
2017 J jnl
CoRR
Christophe Guyeux, Abdallah Makhoul, Jacques M. Bahi
2017 J jnl
CoRR
Christophe Guyeux, Jacques M. Bahi
2017 J jnl
CoRR
Jacques M. Bahi, Xiaole Fang, Christophe Guyeux
2017 J jnl
CoRR
Wiem Elghazel, Jacques M. Bahi, Christophe Guyeux, Mourad Hakem, Kamal Medjaher, Noureddine Zerhouni
2017 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux
2017 J jnl
CoRR
Christophe Guyeux, Qianxue Wang, Xiaole Fang, Jacques M. Bahi
2017 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux, Abdallah Makhoul, Congduc Pham
2017 J jnl
CoRR
Wiem Elghazel, Kamal Medjaher, Nourredine Zerhouni, Jacques M. Bahi, Ahmad Farhat, Christophe Guyeux, Mourad Hakem
2017 J jnl
J. Bioinform. Comput. Biol.
Christophe Guyeux, Stéphane Chrétien, Nathalie M.-L. Côté, Jacques M. Bahi
2017 J jnl
CoRR
Jean-François Couchot, Pierre-Cyrille Héam, Christophe Guyeux, Qianxue Wang, Jacques M. Bahi
2016 J jnl
CoRR
Christophe Guyeux, Jacques M. Bahi
2016 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux, Mourad Hakem, Abdallah Makhoul
2016 J jnl
CoRR
Jacques M. Bahi, Xiaole Fang, Christophe Guyeux, Laurent Larger
2016 J jnl
CoRR
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux, Michel Salomon
2016 J jnl
CoRR
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux
2016 J jnl
CoRR
Xiaole Fang, Christophe Guyeux, Qianxue Wang, Jacques M. Bahi
2016 J jnl
CoRR
Jacques M. Bahi, Wiem Elghazel, Christophe Guyeux, Mohammed Haddad, Mourad Hakem, Kamal Medjaher, Nourredine Zerhouni
2016 J jnl
Comput. J.
Jacques M. Bahi, Wiem Elghazel, Christophe Guyeux, Mohammed Haddad, Mourad Hakem, Kamal Medjaher, Noureddine Zerhouni
2016 J jnl
IEEE Trans. Circuits Syst. I Regul. Pap.
Qianxue Wang, Simin Yu, Chengqing Li, Jinhu Lu, Xiaole Fang, Christophe Guyeux, Jacques M. Bahi
2016 J jnl
CoRR
Qianxue Wang, Simin Yu, Christophe Guyeux, Jacques M. Bahi, Xiaole Fang
2016 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux, Abdallah Makhoul
2016 J jnl
ACM Trans. Internet Techn.
Abdallah Makhoul, Christophe Guyeux, Mourad Hakem, Jacques M. Bahi
2016 J jnl
CoRR
Abdallah Makhoul, Christophe Guyeux, Mourad Hakem, Jacques M. Bahi
2015 J jnl
Int. J. Inf. Technol. Web Eng.
Christophe Guyeux, Abdallah Makhoul, Ibrahim Atoui, Samar Tawbi, Jacques M. Bahi
2015 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux
2015 J jnl
Int. J. Sens. Networks
Abdallah Makhoul, David Laiymani, Hassan Harb, Jacques M. Bahi
2015 J jnl
Comput. Ind.
Wiem Elghazel, Jacques M. Bahi, Christophe Guyeux, Mourad Hakem, Kamal Medjaher, Noureddine Zerhouni
2015 J jnl
J. Supercomput.
Christophe Guyeux, Raphaël Couturier, Pierre-Cyrille Héam, Jacques M. Bahi
2015 conf
AlCoB
Bassam AlKindy, Christophe Guyeux, Jean-François Couchot, Michel Salomon, Christian Parisod, Jacques M. Bahi
2015 J jnl
CoRR
Bassam AlKindy, Christophe Guyeux, Jean-François Couchot, Michel Salomon, Christian Parisod, Jacques M. Bahi
2015 conf
IWBBIO (1)
Bassam AlKindy, Huda Al-Nayyef, Christophe Guyeux, Jean-François Couchot, Michel Salomon, Jacques M. Bahi
2015 J jnl
CoRR
Bassam AlKindy, Huda Al-Nayyef, Christophe Guyeux, Jean-François Couchot, Michel Salomon, Jacques M. Bahi
2015 conf
IWBBIO (1)
Huda Al-Nayyef, Christophe Guyeux, Marie Petitjean, Didier Hocquet, Jacques M. Bahi
2015 C conf
CIBCB
Huda Al-Nayyef, Christophe Guyeux, Jacques M. Bahi
2015 J jnl
J. Bioinform. Comput. Biol.
Christophe Guyeux, Jean-Marc Nicod, Laurent Philippe, Jacques M. Bahi
2015 J jnl
CoRR
Christophe Guyeux, Jacques M. Bahi
2014 C conf
WETICE
Christophe Guyeux, Abdallah Makhoul, Jacques M. Bahi
2014 J jnl
Ad Hoc Sens. Wirel. Networks
Jacques M. Bahi, Abdallah Makhoul, Maguy Medlej
2014 conf
GCB
Huda Al-Nayyef, Christophe Guyeux, Jacques M. Bahi
2014 J jnl
Ad Hoc Networks
Jacques M. Bahi, Mohammed Haddad, Mourad Hakem, Hamamache Kheddouci
2014 J jnl
J. Netw. Comput. Appl.
Jacques M. Bahi, Christophe Guyeux, Mourad Hakem, Abdallah Makhoul
2014 J jnl
J. Inf. Secur. Appl.
Xiaole Fang, Qianxue Wang, Christophe Guyeux, Jacques M. Bahi
2014 J jnl
CoRR
Bassam AlKindy, Jean-François Couchot, Christophe Guyeux, Arnaud Mouly, Michel Salomon, Jacques M. Bahi
2014 J jnl
CoRR
Bassam AlKindy, Christophe Guyeux, Jean-François Couchot, Michel Salomon, Jacques M. Bahi
2014 conf
BIBM
Bassam AlKindy, Christophe Guyeux, Jean-François Couchot, Michel Salomon, Jacques M. Bahi
2014 J jnl
J. Bioinform. Comput. Biol.
Christophe Guyeux, Nathalie M.-L. Côté, Jacques M. Bahi, Wojciech Bienia
2014 J jnl
IEEE Trans. Circuits Syst. I Regul. Pap.
Xiaole Fang, Benjamin Wetzel, Jean-Marc Merolla, John M. Dudley, Laurent Larger, Christophe Guyeux, Jacques M. Bahi
2014 J jnl
J. Supercomput.
Lilia Ziane Khodja, Raphaël Couturier, Arnaud Giersch, Jacques M. Bahi
2014 C conf
SECRYPT
Jean-François Couchot, Pierre-Cyrille Héam, Christophe Guyeux, Qianxue Wang, Jacques M. Bahi
2014 J jnl
J. Netw. Comput. Appl.
Jacques M. Bahi, Xiaole Fang, Christophe Guyeux, Qianxue Wang
2014 J jnl
Int. J. Bifurc. Chaos
Qianxue Wang, Simin Yu, Christophe Guyeux, Jacques M. Bahi, Xiaole Fang
2014 J jnl
Int. J. Auton. Adapt. Commun. Syst.
Jacques M. Bahi, Christophe Guyeux, Abdallah Makhoul
2013 conf
IIH-MSP
Jacques M. Bahi, Christophe Guyeux, Pierre-Cyrille Héam
2013 J jnl
Adv. Eng. Softw.
Ming Chau, Raphaël Couturier, Jacques M. Bahi, Pierre Spitéri
2013 J jnl
Comput. Biol. Chem.
Jacques M. Bahi, Christophe Guyeux, Kamel Mazouzi, Laurent Philippe
2013 J jnl
Comput. Math. Appl.
Lilia Ziane Khodja, Ming Chau, Raphaël Couturier, Jacques M. Bahi, Pierre Spitéri
2013 conf
IIH-MSP
Jacques M. Bahi, Jean-François Couchot, Nicolas Friot, Christophe Guyeux, Kamel Mazouzi
2013 J jnl
Trans. Large Scale Data Knowl. Centered Syst.
Jacques M. Bahi, Mohammed Haddad, Mourad Hakem, Hamamache Kheddouci
2013 conf
AINA Workshops
Jacques M. Bahi, Mohammed Haddad, Mourad Hakem, Hamamache Kheddouci
2013 C conf
SECRYPT
Jacques M. Bahi, Nicolas Friot, Christophe Guyeux
2012 ch.
Computational Intelligence for Privacy and Security
Christophe Guyeux, Jacques M. Bahi
2012 conf
ADHOC-NOW
Jacques M. Bahi, Abdallah Makhoul, Maguy Medlej
2012 J jnl
CoRR
Jacques M. Bahi, Jean-François Couchot, Nicolas Friot, Christophe Guyeux
2012 B conf
NOMS
Jacques M. Bahi, Abdallah Makhoul, Maguy Medlej
2012 J jnl
Int. J. Distributed Sens. Networks
Jacques M. Bahi, Christophe Guyeux, Abdallah Makhoul, Congduc Pham
2012 conf
IIH-MSP
Jacques M. Bahi, Nicolas Friot, Christophe Guyeux
2012 J jnl
CoRR
Jacques M. Bahi, Nicolas Friot, Christophe Guyeux
2012 conf
CSBio
Jacques M. Bahi, Christophe Guyeux, Antoine Perasso
2012 J jnl
Cogn. Comput.
Jacques M. Bahi, Nathalie Côté, Christophe Guyeux, Michel Salomon
2012 J jnl
Comput. J.
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux
2012 J jnl
CoRR
Julien Voisin, Christophe Guyeux, Jacques M. Bahi
2011 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux, Pierre-Cyrille Héam
2011 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux, Michel Salomon
2011 B conf
IJCNN
Jacques M. Bahi, Nathalie Côté, Christophe Guyeux
2011 C conf
SECRYPT
Nicolas Friot, Christophe Guyeux, Jacques M. Bahi
2011 J jnl
CoRR
Nicolas Friot, Christophe Guyeux, Jacques M. Bahi
2011 J jnl
CoRR
Christophe Guyeux, Nicolas Friot, Jacques M. Bahi
2011 J jnl
CoRR
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux, Qianxue Wang
2011 B conf
IWCMC
Jacques M. Bahi, Abdallah Makhoul, Maguy Medlej
2011 C conf
HPCC
Jacques M. Bahi, Mohammed Haddad, Mourad Hakem, Hamamache Kheddouci
2011 J jnl
CoRR
Jacques M. Bahi, Raphaël Couturier, Christophe Guyeux, Pierre-Cyrille Héam
2011 J jnl
CoRR
Jacques M. Bahi, Xiaole Fang, Christophe Guyeux, Qianxue Wang
2011 J jnl
CoRR
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux, Adrien Richard
2011 B conf
FCT
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux, Adrien Richard
2011 J jnl
CoRR
Jacques M. Bahi, Xiaole Fang, Christophe Guyeux, Qianxue Wang
2011 conf
SpringSim (HPC)
Jacques M. Bahi, Raphaël Couturier, Lilia Ziane Khodja
2011 conf
Euro-Par Workshops (1)
Jacques M. Bahi, Raphaël Couturier, Lilia Ziane Khodja
2011 J jnl
Int. J. High Perform. Comput. Appl.
Ming Chau, Raphaël Couturier, Jacques M. Bahi, Pierre Spitéri
2011 J jnl
CoRR
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux
2011 J jnl
CoRR
Jacques M. Bahi, Xiaole Fang, Christophe Guyeux, Qianxue Wang
2011 C conf
AICCSA
Jacques M. Bahi, Mourad Hakem, Abdallah Makhoul
2011 conf
ADHOCNETS
Jacques M. Bahi, Christophe Guyeux, Abdallah Makhoul, Congduc Pham
2011 conf
IIH-MSP
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux
2011 J jnl
CoRR
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux
2011 J jnl
CoRR
Jacques M. Bahi, Jean-François Couchot, Christophe Guyeux
2010 C conf
SECRYPT
Christophe Guyeux, Jacques M. Bahi
2010 C conf
PDCAT
Jacques M. Bahi, Mohammed Haddad, Mourad Hakem, Hamamache Kheddouci
2010 J jnl
CoRR
Christophe Guyeux, Qianxue Wang, Jacques M. Bahi
2010 conf
WISM
Christophe Guyeux, Qianxue Wang, Jacques M. Bahi
2010 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux
2010 J jnl
Comput. Networks
Jacques M. Bahi, Michel Salomon
2010 J jnl
CoRR
Qianxue Wang, Christophe Guyeux, Jacques M. Bahi
2010 conf
IIH-MSP
Christophe Guyeux, Nicolas Friot, Jacques M. Bahi
2010 J jnl
CoRR
Christophe Guyeux, Nicolas Friot, Jacques M. Bahi
2010 C conf
MEDES
Mirna Eskandar, Jacques M. Bahi, Ahmed Mostefaoui
2010 J jnl
CoRR
Christophe Guyeux, Qianxue Wang, Jacques M. Bahi
2010 conf
VECPAR
Jacques M. Bahi, Sylvain Contassot-Vivier, Arnaud Giersch
2010 conf
ADHOCNETS
Jacques M. Bahi, Christophe Guyeux, Abdallah Makhoul
2010 B conf
IJCNN
Christophe Guyeux, Jacques M. Bahi
2009 J jnl
Int. J. High Perform. Comput. Appl.
Jacques M. Bahi, Jean-Claude Charr, Raphaël Couturier, David Laiymani
2009 J jnl
Adv. Eng. Softw.
Jacques M. Bahi, Sylvain Contassot-Vivier, Marc Sauget
2009 J jnl
IEEE Trans. Neural Networks
Jacques M. Bahi, Sylvain Contassot-Vivier
2009 C conf
GPC
Jacques M. Bahi, Raphaël Couturier, David Laiymani, Kamel Mazouzi
2009 J jnl
CoRR
Husam Alustwani, Jacques M. Bahi, Ahmed Mostefaoui, Michel Salomon
2009 J jnl
J. Digit. Inf. Manag.
Jacques M. Bahi, Mirna Eskandar, Ahmed Mostefaoui
2009 conf
Euro-Par Workshops
Jacques M. Bahi, Mourad Hakem, Kamel Mazouzi
2008 conf
VECPAR
Jacques M. Bahi, Sylvain Contassot-Vivier, Marc Sauget, Aurélien Vasseur
2008 conf
ICDIM
Jacques M. Bahi, Mirna Eskandar, Ahmed Mostefaoui
2008 conf
Infoscale
Jacques M. Bahi, Arnaud Giersch, Abdallah Makhoul
2008 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux
2008 J jnl
CoRR
Jacques M. Bahi, Christophe Guyeux
2008 conf
VECPAR
Jacques M. Bahi, Sylvain Contassot-Vivier, Raphaël Couturier
2008 A conf
IPDPS
Jacques M. Bahi, Raphaël Couturier, David Laiymani
2008 J jnl
Int. J. Syst. Sci.
Jacques M. Bahi, Abdallah Makhoul, Ahmed Mostefaoui
2008 C conf
ISM
Husam Alustwani, Jacques M. Bahi, Ahmed Mostefaoui
2008 J jnl
Tech. Sci. Informatiques
Jacques M. Bahi, Raphaël Couturier, Philippe Vuillemin
2008 J jnl
Comput. Commun.
Jacques M. Bahi, Abdallah Makhoul, Ahmed Mostefaoui
2008 J jnl
Int. J. Internet Protoc. Technol.
Husam Alustwani, Jacques M. Bahi, Ahmed Mostefaoui
2008 conf
UbiMob
Jacques M. Bahi, Mirna Eskandar, Ahmed Mostefaoui
2007 conf
APPT
Jacques M. Bahi, Raphaël Couturier, David Laiymani, Kamel Mazouzi
2007 B conf
WiMob
Jacques M. Bahi, Abdallah Makhoul, Ahmed Mostefaoui
2007 C conf
CLUSTER
Jacques M. Bahi, Jean-Claude Charr, Raphaël Couturier, David Laiymani
2007 A conf
IPDPS
Jacques M. Bahi, Raphaël Couturier, David Laiymani, Kamel Mazouzi
2007 conf
PerCom Workshops
Jacques M. Bahi, Abdallah Makhoul, Ahmed Mostefaoui
2007 A conf
IPDPS
Jacques M. Bahi, Raphaël Couturier, Flavien Vernier
2006 conf
MSN
Jacques M. Bahi, Ahmed Mostefaoui, Michel Salomon
2006 J jnl
IEEE Trans. Neural Networks
Jacques M. Bahi, Sylvain Contassot-Vivier
2006 conf
ISPA Workshops
Jacques M. Bahi, Raphaël Couturier, Abderrahmane Sider
2006 conf
SUTC (1)
Amine Abbas, Jacques M. Bahi, Ahmed Mostefaoui
2006 conf
ICON
Jacques M. Bahi, Ahmed Mostefaoui, Michel Salomon
2006 C conf
CLUSTER
Jacques M. Bahi, Raphaël Couturier, Philippe Vuillemin
2006 conf
VECPAR
Jacques M. Bahi, Raphaël Couturier, Philippe Vuillemin
2006 conf
ICDIM
Husam Alustwani, Jacques M. Bahi, Ahmed Mostefaoui
2006 A conf
IPDPS
Jacques M. Bahi, Stéphane Domas, Kamel Mazouzi
2006 conf
ICANN (2)
Jacques M. Bahi, Sylvain Contassot-Vivier, Libor Makovicka, Éric Martin, Marc Sauget
2006 J jnl
J. Supercomput.
Jacques M. Bahi, Sylvain Contassot-Vivier, Raphaël Couturier
2005 J jnl
IEEE Trans. Parallel Distributed Syst.
Jacques M. Bahi, Sylvain Contassot-Vivier, Raphaël Couturier, Flavien Vernier
2005 J jnl
IEEE Trans. Parallel Distributed Syst.
Jacques M. Bahi, Sylvain Contassot-Vivier, Raphaël Couturier
2005 J jnl
Parallel Comput.
Jacques M. Bahi, Sylvain Contassot-Vivier, Raphaël Couturier
2005 conf
PE-WASUN
Amine Abbas, Jacques M. Bahi, Ahmed Mostefaoui
2005 A conf
IPDPS
Jacques M. Bahi, Raphaël Couturier
2005 A conf
IPDPS
Jacques M. Bahi, Raphaël Couturier, Michel Salomon
2005 J jnl
J. Parallel Distributed Comput.
Jacques M. Bahi, Raphaël Couturier, Flavien Vernier
2004 conf
VECPAR
Jacques M. Bahi, Raphaël Couturier, Philippe Vuillemin
2004 A conf
IPDPS
Jacques M. Bahi, Stéphane Domas, Kamel Mazouzi
2004 J jnl
Tech. Sci. Informatiques
Jacques M. Bahi
2004 C conf
PDP
Jacques M. Bahi, Stéphane Domas, Kamel Mazouzi
2004 A conf
IPDPS
Jacques M. Bahi, Sylvain Contassot-Vivier, Raphaël Couturier
2003 Misc conf
PPAM
Jacques M. Bahi, Raphaël Couturier, Flavien Vernier
2003 C conf
PDP
Jacques M. Bahi, Raphaël Couturier, Flavien Vernier
2003 A conf
IPDPS
Jacques M. Bahi, Sylvain Contassot-Vivier, Raphaël Couturier
2002 conf
HPCS
Jacques M. Bahi, Sylvain Contassot-Vivier, Raphaël Couturier
2002 J jnl
Numer. Algorithms
Pierre Spitéri, Jean Claude Miellou, Jacques M. Bahi
2002 J jnl
IEEE Trans. Neural Networks
Jacques M. Bahi, Sylvain Contassot-Vivier
2001 conf
Euro-Par
Jacques M. Bahi, Jaafar Gaber
2001 J jnl
Stud. Inform. Univ.
Jaafar Gaber, Jacques M. Bahi
2000 J jnl
J. Parallel Distributed Comput.
Jacques M. Bahi
2000 J jnl
Int. J. Comput. Math.
Jacques M. Bahi, Christian J. Michel
2000 B conf
ICTAI
Jaafar Gaber, Jacques M. Bahi, Tarek A. El-Ghazawi
1999 J jnl
Parallel Algorithms Appl.
Jacques M. Bahi
1999 J jnl
Simul. Pract. Theory
Jacques M. Bahi, Christian J. Michel
1997 J jnl
Numer. Algorithms
Jacques M. Bahi, Jean Claude Miellou, K. Rhofir
1995 conf
PARCO
Jacques M. Bahi
tests/integration/test_hashes.py
← Index tests/integration/test_hashes.py python
"""
Integration tests for the HashExtractor class.
"""
import pytest
import hashlib
from unittest.mock import Mock, patch, MagicMock

pytestmark = [pytest.mark.integration]


class TestHashExtractorInitialization:
    """Tests for HashExtractor initialization."""

    def test_initialization_elf(self, elf_binary_path, mock_logger):
        """Test initialization with ELF file."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            assert extractor.filepath == elf_binary_path
            assert extractor.hashes is None
            assert extractor.filetype == "elf"
            assert extractor.macho is None

    def test_initialization_with_macho_object(self, elf_binary_path, mock_logger):
        """Test initialization with pre-parsed macho object."""
        from redb.extractors.hashes import HashExtractor

        mock_macho = MagicMock()
        mock_macho.get_architectures.return_value = ["x86_64"]

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger, macho=mock_macho)

            assert extractor.macho is mock_macho

    def test_initialization_pe(self, pe_binary_path, mock_logger):
        """Test initialization with PE file."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(pe_binary_path, mock_logger)

            assert extractor.filepath == pe_binary_path
            assert extractor.filetype == "pebin"
            # PE object should be created
            assert extractor.pe is not None

    def test_elastic_index_suffix(self, elf_binary_path, mock_logger):
        """Test that elastic_index has correct suffix."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            assert "-hashes" in extractor.elastic_index


class TestHashExtractorTag:
    """Tests for tag method."""

    def test_tag_value(self, elf_binary_path, mock_logger):
        """Test that tag returns correct value."""
        from redb.extractors.hashes import HashExtractor
        from redb.extractors.enum import Tag

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            assert extractor.tag() == Tag.HASH.value
            assert extractor.tag() == "hash"


class TestHashExtractorBasicHashes:
    """Tests for basic hash extraction."""

    def test_extract_md5(self, elf_binary_path, mock_logger, known_hashes):
        """Test MD5 hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            assert result.md5 == known_hashes['md5']

    def test_extract_sha1(self, elf_binary_path, mock_logger, known_hashes):
        """Test SHA1 hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            assert result.sha1 == known_hashes['sha1']

    def test_extract_sha256(self, elf_binary_path, mock_logger, known_hashes):
        """Test SHA256 hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            assert result.sha256 == known_hashes['sha256']

    def test_extract_ssdeep(self, elf_binary_path, mock_logger):
        """Test ssdeep hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # ssdeep should be a string
            assert isinstance(result.ssdeep_hash, str)

    def test_extract_tlsh(self, elf_binary_path, mock_logger):
        """Test TLSH hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # TLSH should be a string
            assert isinstance(result.tlsh_hash, str)


class TestHashExtractorPEHashes:
    """Tests for PE-specific hash extraction."""

    def test_extract_imphash(self, pe_binary_path, mock_logger):
        """Test imphash extraction for PE file."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(pe_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # Imphash should be set for PE files
            if extractor.pe is not None:
                assert result.imphash is not None or result.imphash is None  # May or may not have imports

    def test_extract_authentihash(self, pe_binary_path, mock_logger):
        """Test authentihash extraction for PE file."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(pe_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # Authentihash should be set for PE files
            if extractor.pe is not None:
                assert result.authentihash is not None

    def test_pe_hashes_not_set_for_elf(self, elf_binary_path, mock_logger):
        """Test that PE-specific hashes are not set for ELF files."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # PE-specific hashes should be None for ELF
            assert result.imphash is None
            assert result.authentihash is None
            assert result.richhash is None


class TestHashExtractorRichHeaderHashes:
    """Tests for Rich header hash extraction."""

    def test_compute_richhash(self, pe_binary_path, mock_logger):
        """Test Rich header hash computation."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(pe_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # Rich hash may or may not be present depending on the PE
            if result.richhash is not None:
                assert isinstance(result.richhash, str)
                assert len(result.richhash) == 32  # MD5 hex length

    def test_compute_richpe_hash(self, pe_binary_path, mock_logger):
        """Test RichPE hash computation."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(pe_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # RichPE hash may or may not be present
            if result.richpe_hash is not None:
                assert isinstance(result.richpe_hash, str)
                assert len(result.richpe_hash) == 32  # MD5 hex length

    def test_compute_richpv_hash(self, pe_binary_path, mock_logger):
        """Test RichPV hash computation."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(pe_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # RichPV hashes may or may not be present
            if result.richpv_hash is not None:
                assert isinstance(result.richpv_hash, str)
            if result.richpv_hash_sorted is not None:
                assert isinstance(result.richpv_hash_sorted, str)


class TestHashExtractorELFHashes:
    """Tests for ELF-specific hash extraction."""

    def test_extract_elf_import_hash(self, elf_binary_path, mock_logger):
        """Test ELF import hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # Import hash may or may not be present
            if result.import_hash is not None:
                assert isinstance(result.import_hash, str)
                assert len(result.import_hash) == 32

    def test_extract_elf_export_hash(self, elf_binary_path, mock_logger):
        """Test ELF export hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # Export hash may or may not be present
            if result.export_hash is not None:
                assert isinstance(result.export_hash, str)

    def test_extract_elf_section_hash(self, elf_binary_path, mock_logger):
        """Test ELF section hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # Section hash should be present for valid ELF
            if result.section_hash is not None:
                assert isinstance(result.section_hash, str)

    def test_extract_elf_symbol_hash(self, elf_binary_path, mock_logger):
        """Test ELF symbol hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # Symbol hash (symhash) may or may not be present
            if result.symbol_hash is not None:
                assert isinstance(result.symbol_hash, str)

    def test_extract_elf_dynamic_hash(self, elf_binary_path, mock_logger):
        """Test ELF dynamic hash extraction."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            # Dynamic hash may or may not be present
            if result.dynamic_hash is not None:
                assert isinstance(result.dynamic_hash, str)


class TestHashExtractorPrepareExportData:
    """Tests for prepare_export_data method."""

    def test_prepare_export_elasticsearch(self, elf_binary_path, mock_logger):
        """Test prepare_export_data for Elasticsearch."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)
            extractor.extract()

            result = extractor.prepare_export_data("ElasticsearchExporter")

            assert result is extractor.hashes

    def test_prepare_export_clickhouse(self, elf_binary_path, mock_logger):
        """Test prepare_export_data for ClickHouse."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)
            extractor.extract()

            result = extractor.prepare_export_data("ClickHouseExporter")

            # Should return tuple of (data, column_names, column_type_names)
            assert isinstance(result, tuple)
            assert len(result) == 3

            data, column_names, column_type_names = result

            assert isinstance(data, list)
            assert isinstance(column_names, list)
            assert isinstance(column_type_names, list)

            # Check expected columns
            assert 'sha256' in column_names
            assert 'md5' in column_names
            assert 'sha1' in column_names
            assert 'ssdeep_hash' in column_names
            assert 'tlsh_hash' in column_names

    def test_prepare_export_clickhouse_pe(self, pe_binary_path, mock_logger):
        """Test prepare_export_data for ClickHouse with PE file."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(pe_binary_path, mock_logger)
            extractor.extract()

            result = extractor.prepare_export_data("ClickHouseExporter")

            data, column_names, column_type_names = result

            # PE-specific columns should be present
            assert 'authentihash' in column_names
            assert 'imphash' in column_names
            assert 'richhash' in column_names

    def test_prepare_export_clickhouse_has_macho_columns(self, elf_binary_path, mock_logger):
        """Test prepare_export_data for ClickHouse includes Mach-O hash columns."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)
            extractor.extract()

            result = extractor.prepare_export_data("ClickHouseExporter")

            data, column_names, column_type_names = result

            # Mach-O hash columns should be present
            assert 'macho_dylib_hash' in column_names
            assert 'macho_import_hash' in column_names
            assert 'macho_export_hash' in column_names
            assert 'macho_entitlement_hash' in column_names
            assert 'macho_symhash' in column_names


class TestHashExtractorClickHouseTable:
    """Tests for get_clickhouse_table method."""

    def test_clickhouse_table_name(self, elf_binary_path, mock_logger):
        """Test correct ClickHouse table name."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            assert extractor.get_clickhouse_table() == "redb_hashes"


@pytest.mark.unit
@pytest.mark.dataclass
class TestHashExtractorHashesDataclass:
    """Tests for Hashes dataclass structure."""

    def test_hashes_dataclass_structure(self, elf_binary_path, mock_logger):
        """Test that Hashes dataclass has expected structure."""
        from redb.extractors.hashes import HashExtractor
        from redb.models.dataclasses import Hashes

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert isinstance(result, Hashes)
            # Required fields
            assert hasattr(result, 'md5')
            assert hasattr(result, 'sha1')
            assert hasattr(result, 'sha256')
            assert hasattr(result, 'ssdeep_hash')
            assert hasattr(result, 'tlsh_hash')
            # Optional fields
            assert hasattr(result, 'authentihash')
            assert hasattr(result, 'imphash')
            assert hasattr(result, 'richhash')

    def test_hashes_dataclass_has_macho_fields(self):
        """Test that Hashes dataclass has Mach-O hash fields."""
        from redb.models.dataclasses import Hashes

        # Create instance with default values
        hashes = Hashes(
            md5="d41d8cd98f00b204e9800998ecf8427e",
            sha1="da39a3ee5e6b4b0d3255bfef95601890afd80709",
            sha256="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            ssdeep_hash="",
            tlsh_hash=""
        )

        # Verify Mach-O hash fields exist and default to None
        assert hasattr(hashes, 'macho_dylib_hash')
        assert hasattr(hashes, 'macho_import_hash')
        assert hasattr(hashes, 'macho_export_hash')
        assert hasattr(hashes, 'macho_entitlement_hash')
        assert hasattr(hashes, 'macho_symhash')

        assert hashes.macho_dylib_hash is None
        assert hashes.macho_import_hash is None
        assert hashes.macho_export_hash is None
        assert hashes.macho_entitlement_hash is None
        assert hashes.macho_symhash is None

    def test_hashes_dataclass_with_macho_values(self):
        """Test that Hashes dataclass can be created with Mach-O hash values."""
        from redb.models.dataclasses import Hashes

        hashes = Hashes(
            md5="d41d8cd98f00b204e9800998ecf8427e",
            sha1="da39a3ee5e6b4b0d3255bfef95601890afd80709",
            sha256="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            ssdeep_hash="",
            tlsh_hash="",
            macho_dylib_hash="abc123def456789012345678901234567",
            macho_import_hash="def456abc123789012345678901234567",
            macho_export_hash="789012abc123def456345678901234567",
            macho_entitlement_hash="345678abc123def456789012901234567",
            macho_symhash="901234abc123def456789012345678567"
        )

        assert hashes.macho_dylib_hash == "abc123def456789012345678901234567"
        assert hashes.macho_import_hash == "def456abc123789012345678901234567"
        assert hashes.macho_export_hash == "789012abc123def456345678901234567"
        assert hashes.macho_entitlement_hash == "345678abc123def456789012901234567"
        assert hashes.macho_symhash == "901234abc123def456789012345678567"


class TestHashExtractorErrorHandling:
    """Tests for error handling in HashExtractor."""

    def test_extract_handles_hash_errors(self, elf_binary_path, mock_logger):
        """Test that extract handles hash computation errors gracefully."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            # Even if some hashes fail, we should get a result
            result = extractor.extract()

            assert result is not None

    def test_extract_with_invalid_pe(self, elf_binary_path, mock_logger):
        """Test extraction when PE parsing fails."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            # Force filetype to be 'pebin' but use ELF file
            with patch.object(HashExtractor, '__init__', lambda self, *args, **kwargs: None):
                extractor = HashExtractor.__new__(HashExtractor)
                extractor.filepath = elf_binary_path
                extractor.log = mock_logger
                extractor.hashes = None
                extractor.pe = None
                extractor.filetype = 'pebin'

                with open(elf_binary_path, 'rb') as f:
                    extractor.binary = f.read()

                # Should not crash
                result = extractor._extract_hashes()
                assert result is not None


class TestHashExtractorMachoHashes:
    """Tests for Mach-O specific hash extraction."""

    def test_macho_hashes_not_set_for_elf(self, elf_binary_path, mock_logger):
        """Test that Mach-O hashes are not set for ELF files."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            assert result.macho_dylib_hash is None
            assert result.macho_import_hash is None
            assert result.macho_export_hash is None
            assert result.macho_entitlement_hash is None
            assert result.macho_symhash is None

    def test_macho_hashes_not_set_for_pe(self, pe_binary_path, mock_logger):
        """Test that Mach-O hashes are not set for PE files."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(pe_binary_path, mock_logger)

            result = extractor.extract()

            assert result is not None
            assert result.macho_dylib_hash is None
            assert result.macho_import_hash is None
            assert result.macho_export_hash is None
            assert result.macho_entitlement_hash is None
            assert result.macho_symhash is None

    def test_extract_macho_hashes_with_mock(self, elf_binary_path, mock_logger):
        """Test Mach-O hash extraction with mocked macho object."""
        from redb.extractors.hashes import HashExtractor

        # Create mock macho object
        mock_macho = MagicMock()
        mock_macho.get_architectures.return_value = ["x86_64"]
        mock_macho.get_similarity_hashes.return_value = {
            'dylib_hash': 'abc123def456789012345678901234ab',
            'import_hash': 'def456abc789012345678901234567cd',
            'export_hash': '789012abc456def345678901234567ef',
            'entitlement_hash': '345678abc123def789012901234567gh',
            'symhash': '901234abc123def456789012345678ij'
        }

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger, macho=mock_macho)
            # Override filetype to trigger macho hash extraction
            extractor.filetype = 'macho'

            result = extractor.extract()

            assert result is not None
            assert result.macho_dylib_hash == 'abc123def456789012345678901234ab'
            assert result.macho_import_hash == 'def456abc789012345678901234567cd'
            assert result.macho_export_hash == '789012abc456def345678901234567ef'
            assert result.macho_entitlement_hash == '345678abc123def789012901234567gh'
            assert result.macho_symhash == '901234abc123def456789012345678ij'

    def test_extract_macho_hashes_fat_binary_mock(self, elf_binary_path, mock_logger):
        """Test Mach-O hash extraction for FAT binary with mocked macho object."""
        from redb.extractors.hashes import HashExtractor

        # Create mock macho object for FAT binary
        mock_macho = MagicMock()
        mock_macho.get_architectures.return_value = ["x86_64", "arm64"]  # Multiple archs = FAT
        mock_macho.get_similarity_hashes.return_value = {
            'fat': {
                'dylib_hash': 'fat_dylib_hash_12345678901234567',
                'import_hash': 'fat_import_hash_12345678901234567',
            },
            'combined': {
                'dylib_hash': 'combined_dylib_hash_1234567890123',
            }
        }

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger, macho=mock_macho)
            extractor.filetype = 'macho'

            result = extractor.extract()

            assert result is not None
            # Should use 'fat' key for FAT binaries
            assert result.macho_dylib_hash == 'fat_dylib_hash_12345678901234567'
            assert result.macho_import_hash == 'fat_import_hash_12345678901234567'

    def test_extract_macho_hashes_handles_empty(self, elf_binary_path, mock_logger):
        """Test Mach-O hash extraction handles empty hash dict."""
        from redb.extractors.hashes import HashExtractor

        mock_macho = MagicMock()
        mock_macho.get_architectures.return_value = ["x86_64"]
        mock_macho.get_similarity_hashes.return_value = {}

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger, macho=mock_macho)
            extractor.filetype = 'macho'

            result = extractor.extract()

            # Should not crash, hashes should be None
            assert result is not None
            assert result.macho_dylib_hash is None

    def test_extract_macho_hashes_handles_none(self, elf_binary_path, mock_logger):
        """Test Mach-O hash extraction handles None return."""
        from redb.extractors.hashes import HashExtractor

        mock_macho = MagicMock()
        mock_macho.get_architectures.return_value = ["x86_64"]
        mock_macho.get_similarity_hashes.return_value = None

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger, macho=mock_macho)
            extractor.filetype = 'macho'

            result = extractor.extract()

            # Should not crash
            assert result is not None


class TestHashExtractorConsistency:
    """Tests for hash consistency."""

    def test_hash_consistency_across_extractions(self, elf_binary_path, mock_logger):
        """Test that hashes are consistent across multiple extractions."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor1 = HashExtractor(elf_binary_path, mock_logger)
            result1 = extractor1.extract()

            extractor2 = HashExtractor(elf_binary_path, mock_logger)
            result2 = extractor2.extract()

            assert result1.md5 == result2.md5
            assert result1.sha1 == result2.sha1
            assert result1.sha256 == result2.sha256

    def test_hash_values_are_lowercase(self, elf_binary_path, mock_logger):
        """Test that hash values are lowercase hex strings."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert result.md5 == result.md5.lower()
            assert result.sha1 == result.sha1.lower()
            assert result.sha256 == result.sha256.lower()

    def test_hash_lengths_correct(self, elf_binary_path, mock_logger):
        """Test that hash lengths are correct."""
        from redb.extractors.hashes import HashExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = HashExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()

            assert len(result.md5) == 32  # MD5 = 128 bits = 32 hex chars
            assert len(result.sha1) == 40  # SHA1 = 160 bits = 40 hex chars
            assert len(result.sha256) == 64  # SHA256 = 256 bits = 64 hex chars