Search in sources :

Example 6 with ChatMessageValidator

use of de.tum.in.tumcampusapp.component.ui.chat.ChatMessageValidator in project TumCampusApp by TCA-Team.

the class ChatMessageValidatorTestCase method testAsciiValidMessageOneKey.

/**
 * Tests that a valid ASCII-based message is correctly found as valid when
 * there is only one public key associated to the validator.
 */
@Test
public void testAsciiValidMessageOneKey() {
    validator = new ChatMessageValidator(buildPubkeyList(0, 1));
    ChatMessage message = messageFixtures.get(0);
    assertTrue(validator.validate(message));
}
Also used : ChatMessage(de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage) ChatMessageValidator(de.tum.in.tumcampusapp.component.ui.chat.ChatMessageValidator) Test(org.junit.Test)

Example 7 with ChatMessageValidator

use of de.tum.in.tumcampusapp.component.ui.chat.ChatMessageValidator in project TumCampusApp by TCA-Team.

the class ChatMessageValidatorTestCase method testInvalidBase64Signature.

/**
 * Tests that when the signature is not a valid base64 string, the validator
 * simply says the message is not valid.
 */
@Test
public void testInvalidBase64Signature() {
    validator = new ChatMessageValidator(buildPubkeyList(0, 1));
    ChatMessage message = buildChatMessage("This is a message!", "This is not valid base64...");
    assertFalse(validator.validate(message));
}
Also used : ChatMessage(de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage) ChatMessageValidator(de.tum.in.tumcampusapp.component.ui.chat.ChatMessageValidator) Test(org.junit.Test)

Aggregations

ChatMessageValidator (de.tum.in.tumcampusapp.component.ui.chat.ChatMessageValidator)7 ChatMessage (de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage)7 Test (org.junit.Test)7 ChatPublicKey (de.tum.in.tumcampusapp.component.ui.chat.model.ChatPublicKey)2 ArrayList (java.util.ArrayList)1