File: smp_test.go

package info (click to toggle)
golang-github-twstrike-otr3 0.0~git20161015.0.744856d-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,008 kB
  • ctags: 1,863
  • sloc: ansic: 127; makefile: 76
file content (27 lines) | stat: -rw-r--r-- 976 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
package otr3

import "testing"

func Test_generateSMPSecretGeneratesASecret(t *testing.T) {
	aliceFingerprint := bytesFromHex("0102030405060708090A0B0C0D0E0F1011121314")
	bobFingerprint := bytesFromHex("3132333435363738393A3B3C3D3E3F4041424344")
	ssid := bytesFromHex("FFF1D1E412345668")
	secret := []byte("this is something secret")
	result := generateSMPSecret(aliceFingerprint, bobFingerprint, ssid, secret, otrV3{})
	assertDeepEquals(t, result, bnFromHex("D9B2E56321F9A9F8E364607C8C82DECD8E8E6209E2CB952C7E649620F5286FE3"))
}

func Test_SMPQuestion_returnsTheCurrentSMPQuestion(t *testing.T) {
	c := newConversation(otrV3{}, fixtureRand())
	q := "Are all greeks liars?"
	c.smp.question = &q
	res, ok := c.SMPQuestion()
	assertEquals(t, ok, true)
	assertDeepEquals(t, res, "Are all greeks liars?")
}

func Test_SMPQuestion_returnsNotOKIfThereIsNoQuestion(t *testing.T) {
	c := newConversation(otrV3{}, fixtureRand())
	_, ok := c.SMPQuestion()
	assertEquals(t, ok, false)
}