Search in sources :

Example 1 with ChatPublicKey

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

the class ChatMessageValidatorTestCase method testOneInvalidKey.

/**
 * Tests that a message is found valid regardless of the fact that there is one invalid
 * key in the list of public keys.
 */
@Test
public void testOneInvalidKey() {
    List<ChatPublicKey> list = new ArrayList<>();
    list.add(new ChatPublicKey("This is not a valid key"));
    list.add(publicKeyFixtures.get(0));
    validator = new ChatMessageValidator(list);
    ChatMessage message = messageFixtures.get(0);
    assertTrue(validator.validate(message));
}
Also used : ChatMessage(de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage) ArrayList(java.util.ArrayList) ChatPublicKey(de.tum.in.tumcampusapp.component.ui.chat.model.ChatPublicKey) ChatMessageValidator(de.tum.in.tumcampusapp.component.ui.chat.ChatMessageValidator) Test(org.junit.Test)

Example 2 with ChatPublicKey

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

the class ChatMessageValidatorTestCase method testInvalidBase64PublicKey.

/**
 * Tests that when the public key associated with the validator is not a valid
 * base64 string, the validator simply says the message is not valid.
 */
@Test
public void testInvalidBase64PublicKey() {
    List<ChatPublicKey> list = buildPubkeyList(0, 1);
    list.get(0).setKey("This is not valid base 64");
    validator = new ChatMessageValidator(list);
    ChatMessage message = messageFixtures.get(0);
    assertFalse(validator.validate(message));
}
Also used : ChatMessage(de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage) ChatPublicKey(de.tum.in.tumcampusapp.component.ui.chat.model.ChatPublicKey) ChatMessageValidator(de.tum.in.tumcampusapp.component.ui.chat.ChatMessageValidator) Test(org.junit.Test)

Example 3 with ChatPublicKey

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

the class ChatMessageValidatorTestCase method setUp.

@Before
public void setUp() {
    publicKeyFixtures = new ArrayList<>();
    publicKeyFixtures.add(new ChatPublicKey("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDR4+3zbRYVRAecvMcn0vLswZAI1z7JqQ2Q0Mkq\n" + "ZAy78cE/tja8qcD4DXXiQYCKC8BdI68W+DqYLohPuOs6rTYfD/pLsbPKaJLHEb4dw0Uchq36pb60\n" + "6G6aCjZrYM0JJYO/pKbwl6ceF6EJRacGswUQ8qY3ZYd6W7R3J7MQxzJ+lQIDAQAB"));
    messageFixtures = new ArrayList<>();
    messageFixtures.add(buildChatMessage("This is a message!", "MwBZFVhzIGehiGAVaoxp0k04BJN8YyyqlPQg1hXwg1bQxgjtEXz6KsVzYOWo40/TdhcbUHo+hUhk\n" + "/rLLBrkFldQuNGhd/ltwiMeN2KwdLYm5nl9DWIjPXXviCBogkVtwrBdAhgknr5Kn5Zy4TbGdMr9z\n" + "d/iOl27L7GYepazgNW8="));
    messageFixtures.add(buildChatMessage("A message with German characters: öäüßÖÄÜ!", "qCOAmFho4tKW24qn6vv6j0x4jc3OVKPbVVm7EqYeJKBStGOmEcx6Crtx0MEMFxNe4Zyqo0kYMXNO\n" + "/NPTvhUJlAr5x6Hlc1iKWBT5eGE8F3mKE8pTSObrCWhEBXylQjkwej5eQpahW+uexZWzeme702V0\n" + "1C3FoeYUC9rSOfLlyss="));
    messageFixtures.add(buildChatMessage("This is a Korean message: \uC88B\uC740 \uAC8C\uC784", "L6DPFzKiVWrO3TeAjJwPNtC4U5D69ODloH3zmCXCpZx+fiZhopzC5cUAeolm2l/++KYZu3vR6IJK\n" + "HLjXaMd4jDruY8DiWNmCbOnR/ywHQ96sCuMcdfhot5AgM05NbBH7GiAFBDJQzDejuK7M7hGmHZ6s\n" + "L4WYKETiNiP1Oc6d58w="));
}
Also used : ChatPublicKey(de.tum.in.tumcampusapp.component.ui.chat.model.ChatPublicKey) Before(org.junit.Before)

Aggregations

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