mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestMessageRouterImpl.java
@Test
    public void testUnsupportedEncryption()
    {
        TerraHarvestMessage baseMessage = TerraHarvestMessageHelper.createBaseMessage();
        
        //change the encryption type
        TerraHarvestMessage.Builder builder = baseMessage.toBuilder();
        baseMessage = builder.setEncryptType(EncryptType.NONE).setIsResponse(true).build();
                
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        when(channel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.AES_ECDH_ECDSA);
        
        // replay
        m_SUT.handleMessage(baseMessage, channel);
        
        TerraHarvestMessage testMessage = TerraHarvestMessageUtil.buildEncryptionErrorResponseMessage(baseMessage, 
            EncryptionErrorCode.INVALID_ENCRYPTION_LEVEL, 
            String.format("System %s does not support type NONE encryption.", m_SystemId), 
            EncryptionMode.AES_ECDH_ECDSA);
        
        // verify error response is queued from the channel
        verify(channel).queueMessage(testMessage);
    }
/**
     * Verify if a message is received and the encryption type is none, but the system is set to a level 
     * that an error response is sent.
     *  
     */
Verify if a message is received and the encryption type is none, but the system is set to a level
that an error response is sent.
Verify if a message is received and the encryption type is none but the system is set to a level that an error response is sent .
@Test
    public void testUnsupportedEncryption()
    {
        TerraHarvestMessage baseMessage = TerraHarvestMessageHelper.createBaseMessage();
        TerraHarvestMessage.Builder builder = baseMessage.toBuilder();
        baseMessage = builder.setEncryptType(EncryptType.NONE).setIsResponse(true).build();
        RemoteChannel channel = mock(RemoteChannel.class);
        when(channel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.AES_ECDH_ECDSA);
        m_SUT.handleMessage(baseMessage, channel);
        TerraHarvestMessage testMessage = TerraHarvestMessageUtil.buildEncryptionErrorResponseMessage(baseMessage, 
            EncryptionErrorCode.INVALID_ENCRYPTION_LEVEL, 
            String.format("System %s does not support type NONE encryption.", m_SystemId), 
            EncryptionMode.AES_ECDH_ECDSA);
        verify(channel).queueMessage(testMessage);
    }
@ Test public void testUnsupportedEncryption ( ) { TerraHarvestMessage baseMessage = TerraHarvestMessageHelper . createBaseMessage ( ) ; TerraHarvestMessage . Builder builder = baseMessage . toBuilder ( ) ; baseMessage = builder . setEncryptType ( EncryptType . NONE ) . setIsResponse ( true ) . build ( ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; when ( channel . queueMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( true ) ; when ( m_RemoteSettings . getEncryptionMode ( ) ) . thenReturn ( EncryptionMode . AES_ECDH_ECDSA ) ; m_SUT . handleMessage ( baseMessage , channel ) ; TerraHarvestMessage testMessage = TerraHarvestMessageUtil . buildEncryptionErrorResponseMessage ( baseMessage , EncryptionErrorCode . INVALID_ENCRYPTION_LEVEL , String . format ( "System %s does not support type NONE encryption." , m_SystemId ) , EncryptionMode . AES_ECDH_ECDSA ) ; verify ( channel ) . queueMessage ( testMessage ) ; }
Verify if a message is received and the encryption type is none, but the system is set to a level
 that an error response is sent.
Verify if a message is received and the encryption type is none but the system is set to a level that an error response is sent .
//change the encryption type // mock the channel the message came from // replay // verify error response is queued from the channel