mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestMessageRouterImpl.java
@Test
    public void testAdaptiveEncryption() throws Exception
    {
        TerraHarvestMessage baseMessage = TerraHarvestMessageHelper.createBaseMessage();
        
        //change the encryption type
        TerraHarvestMessage.Builder builder = baseMessage.toBuilder();
        baseMessage = builder.setEncryptType(EncryptType.AES_ECDH_ECDSA).setIsResponse(true).build();
        
        //payload
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(baseMessage.getTerraHarvestPayload());
                
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        when(channel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        
        //encryption service behavior
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.NONE);
        when(m_EcryptService.decryptRemoteMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(payload);
        
        MessageService baseMessageService = mock(MessageService.class);
        when(baseMessageService.getNamespace()).thenReturn(Namespace.Base);
        m_SUT.bindMessageService(baseMessageService);
        
        // replay
        m_SUT.handleMessage(baseMessage, channel);
        
        // verify proper message service is sent the same message
        verify(baseMessageService).handleMessage(baseMessage, payload, channel);
        
        // verify no error response is queued from the channel
        verify(channel, never()).queueMessage(Mockito.any(TerraHarvestMessage.class));
    }
/**
     * Verify if a message is received and the encryption type is ECDH, but the system is set to a NONE 
     * that the message is attempted to be handled.
     *  
     */
Verify if a message is received and the encryption type is ECDH, but the system is set to a NONE
that the message is attempted to be handled.
Verify if a message is received and the encryption type is ECDH but the system is set to a NONE that the message is attempted to be handled .
@Test
    public void testAdaptiveEncryption() throws Exception
    {
        TerraHarvestMessage baseMessage = TerraHarvestMessageHelper.createBaseMessage();
        TerraHarvestMessage.Builder builder = baseMessage.toBuilder();
        baseMessage = builder.setEncryptType(EncryptType.AES_ECDH_ECDSA).setIsResponse(true).build();
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(baseMessage.getTerraHarvestPayload());
        RemoteChannel channel = mock(RemoteChannel.class);
        when(channel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.NONE);
        when(m_EcryptService.decryptRemoteMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(payload);
        MessageService baseMessageService = mock(MessageService.class);
        when(baseMessageService.getNamespace()).thenReturn(Namespace.Base);
        m_SUT.bindMessageService(baseMessageService);
        m_SUT.handleMessage(baseMessage, channel);
        verify(baseMessageService).handleMessage(baseMessage, payload, channel);
        verify(channel, never()).queueMessage(Mockito.any(TerraHarvestMessage.class));
    }
@ Test public void testAdaptiveEncryption ( ) throws Exception { TerraHarvestMessage baseMessage = TerraHarvestMessageHelper . createBaseMessage ( ) ; TerraHarvestMessage . Builder builder = baseMessage . toBuilder ( ) ; baseMessage = builder . setEncryptType ( EncryptType . AES_ECDH_ECDSA ) . setIsResponse ( true ) . build ( ) ; TerraHarvestPayload payload = TerraHarvestPayload . parseFrom ( baseMessage . getTerraHarvestPayload ( ) ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; when ( channel . queueMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( true ) ; when ( m_RemoteSettings . getEncryptionMode ( ) ) . thenReturn ( EncryptionMode . NONE ) ; when ( m_EcryptService . decryptRemoteMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( payload ) ; MessageService baseMessageService = mock ( MessageService . class ) ; when ( baseMessageService . getNamespace ( ) ) . thenReturn ( Namespace . Base ) ; m_SUT . bindMessageService ( baseMessageService ) ; m_SUT . handleMessage ( baseMessage , channel ) ; verify ( baseMessageService ) . handleMessage ( baseMessage , payload , channel ) ; verify ( channel , never ( ) ) . queueMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ; }
Verify if a message is received and the encryption type is ECDH, but the system is set to a NONE
 that the message is attempted to be handled.
Verify if a message is received and the encryption type is ECDH but the system is set to a NONE that the message is attempted to be handled .
//change the encryption type //payload // mock the channel the message came from //encryption service behavior // replay // verify proper message service is sent the same message // verify no error response is queued from the channel