forked from creamlike1024/EasyLPAC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.go
35 lines (32 loc) · 1.22 KB
/
utils_test.go
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
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestDecodeLpaActivationCode(t *testing.T) {
var info PullInfo
var codeNeeded bool
var err error
_, _, err = DecodeLpaActivationCode("")
assert.Error(t, err)
_, _, err = DecodeLpaActivationCode("LPA:")
assert.Error(t, err)
_, _, err = DecodeLpaActivationCode("LPA:1")
assert.Error(t, err)
info, _, err = DecodeLpaActivationCode("LPA:1$example.com")
assert.NoError(t, err)
assert.Equal(t, "example.com", info.SMDP)
info, _, err = DecodeLpaActivationCode("LPA:1$example.com$matching-id")
assert.Equal(t, "example.com", info.SMDP)
assert.Equal(t, "matching-id", info.MatchID)
info, codeNeeded, err = DecodeLpaActivationCode("LPA:1$example.com$matching-id$$1")
assert.Equal(t, "example.com", info.SMDP)
assert.Equal(t, "matching-id", info.MatchID)
assert.True(t, codeNeeded, "Confirm Code Required Flag")
}
func TestCompleteActivationCode(t *testing.T) {
const lpaString = "LPA:1$example.com$matching-id"
assert.Equal(t, lpaString, CompleteActivationCode("LPA:1$example.com$matching-id"))
assert.Equal(t, lpaString, CompleteActivationCode("1$example.com$matching-id"))
assert.Equal(t, lpaString, CompleteActivationCode("$example.com$matching-id"))
}