File: message_type_test.go

package info (click to toggle)
golang-github-twstrike-otr3 0.0~git20161015.0.744856d-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,080 kB
  • sloc: ansic: 127; makefile: 76
file content (64 lines) | stat: -rw-r--r-- 2,765 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package otr3

import "testing"

func Test_guessMessageType_correctlyIdentifiesAMessageWithWhitespaceTags(t *testing.T) {
	msg := append([]byte("Hello world"), whitespaceTagHeader...)

	assertEquals(t, guessMessageType(msg), msgGuessTaggedPlaintext)
}

func Test_guessMessageType_correctlyIdentifiesAMessageWithNoOTRContent(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("Hello world")), msgGuessNotOTR)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeADHCommit(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR:AAMC")), msgGuessDHCommit)
	assertEquals(t, guessMessageType([]byte("?OTR:AAIC")), msgGuessDHCommit)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeADHKey(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR:AAMK")), msgGuessDHKey)
	assertEquals(t, guessMessageType([]byte("?OTR:AAIK")), msgGuessDHKey)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeARevealSig(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR:AAMR")), msgGuessRevealSig)
	assertEquals(t, guessMessageType([]byte("?OTR:AAIR")), msgGuessRevealSig)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeASignature(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR:AAMS")), msgGuessSignature)
	assertEquals(t, guessMessageType([]byte("?OTR:AAIS")), msgGuessSignature)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeAData(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR:AAMD")), msgGuessData)
	assertEquals(t, guessMessageType([]byte("?OTR:AAID")), msgGuessData)
	assertEquals(t, guessMessageType([]byte("?OTR:AAED")), msgGuessData)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeAQuery(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR?")), msgGuessQuery)
	assertEquals(t, guessMessageType([]byte("?OTRv")), msgGuessQuery)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeAV1KeyExch(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR:AAEK")), msgGuessV1KeyExch)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeAnError(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR Error:")), msgGuessError)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeSomethingElse(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR Weird:")), msgGuessUnknown)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeV3Fragment(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR|")), msgGuessFragment)
}

func Test_guessMessageType_correctlyIdentifiesAMessageThatLooksLikeV2Fragment(t *testing.T) {
	assertEquals(t, guessMessageType([]byte("?OTR,")), msgGuessFragment)
}