|
1 | 1 | package otr3
|
2 | 2 |
|
3 |
| -import "testing" |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | +) |
4 | 6 |
|
5 |
| -func Test_receiveQueryMessage_ignoreAdditionaltext(t *testing.T) { |
| 7 | +func Test_receiveQueryMessage_ignoreVersion1(t *testing.T) { |
| 8 | + queryMsg := []byte("?OTR?") |
| 9 | + |
| 10 | + c := &Conversation{Policies: policies(allowV2 | allowV3)} |
| 11 | + c.SetOurKeys([]PrivateKey{bobPrivateKey}) |
| 12 | + msg, err := c.receiveQueryMessage(queryMsg) |
| 13 | + |
| 14 | + expError := OtrError{msg: "unsupported OTR version", conflict: false} |
| 15 | + assertEquals(t, err, expError) |
| 16 | + assertNil(t, msg) |
| 17 | +} |
| 18 | + |
| 19 | +func Test_receiveQueryMessage_ignoreVersion1AndSupportVersion2(t *testing.T) { |
| 20 | + queryMsg := []byte("?OTR?v2?") |
| 21 | + |
| 22 | + c := &Conversation{Policies: policies(allowV2 | allowV3)} |
| 23 | + c.SetOurKeys([]PrivateKey{bobPrivateKey}) |
| 24 | + msg, err := c.receiveQueryMessage(queryMsg) |
| 25 | + |
| 26 | + assertNil(t, err) |
| 27 | + assertEquals(t, c.ake.state, authStateAwaitingDHKey{}) |
| 28 | + assertDeepEquals(t, dhMsgType(msg[0]), msgTypeDHCommit) |
| 29 | + assertDeepEquals(t, dhMsgVersion(msg[0]), uint16(2)) |
| 30 | +} |
| 31 | + |
| 32 | +func Test_receiveQueryMessage_ignoreBizarreClaim(t *testing.T) { |
| 33 | + queryMsg := []byte("?OTRv?") |
| 34 | + |
| 35 | + c := &Conversation{Policies: policies(allowV2 | allowV3)} |
| 36 | + c.SetOurKeys([]PrivateKey{bobPrivateKey}) |
| 37 | + msg, err := c.receiveQueryMessage(queryMsg) |
| 38 | + |
| 39 | + expError := OtrError{msg: "unsupported OTR version", conflict: false} |
| 40 | + assertEquals(t, err, expError) |
| 41 | + assertNil(t, msg) |
| 42 | +} |
| 43 | + |
| 44 | +func Test_receiveQueryMessage_ignoreAdditionalText(t *testing.T) { |
6 | 45 | queryMsg := []byte("?OTRv2? I like number 3")
|
7 | 46 |
|
8 | 47 | c := &Conversation{Policies: policies(allowV2 | allowV3)}
|
|
0 commit comments