-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_test.go
More file actions
36 lines (32 loc) · 839 Bytes
/
client_test.go
File metadata and controls
36 lines (32 loc) · 839 Bytes
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
package emarsys
import (
"fmt"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestClient_generateWSSE(t *testing.T) {
c, _ := MakeClient(
WithTime(func() time.Time {
return time.Date(2023, 2, 6, 0, 0, 0, 0, time.UTC)
}),
WithCredentials("userX", "passY"),
)
got := c.generateWSSE()
var userName, pwd, nonce, created string
_, err := fmt.Fscanf(
strings.NewReader(got),
"UsernameToken Username=%q,PasswordDigest=%q,Nonce=%q,Created=%q",
&userName,
&pwd,
&nonce,
&created,
)
require.NoError(t, err)
assert.Exactly(t, "userX", userName)
assert.Exactly(t, "NGE4MWNkMWUwZDVjYjlhNjVkOWMzODk3ZGRmNGMwODlmYWMzMWMwNg==", pwd)
assert.Exactly(t, "VqRNlECxJcvmZpKDdXKpZNoXZeNZLAJbSZiP", nonce)
assert.Exactly(t, "2023-02-06T00:00:00Z", created)
}