-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathapps_session_transfer_test.go
More file actions
67 lines (57 loc) · 1.99 KB
/
Copy pathapps_session_transfer_test.go
File metadata and controls
67 lines (57 loc) · 1.99 KB
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
65
66
67
package display
import (
"testing"
"github.com/auth0/go-auth0"
"github.com/auth0/go-auth0/management"
"github.com/stretchr/testify/assert"
)
func TestMakeSessionTransferView_WithoutDelegation(t *testing.T) {
client := &management.Client{
ClientID: auth0.String("client-id"),
SessionTransfer: &management.SessionTransfer{
CanCreateSessionTransferToken: auth0.Bool(true),
AllowedAuthenticationMethods: &[]string{"cookie", "query"},
EnforceDeviceBinding: auth0.String("ip"),
},
}
view := MakeSessionTransferView(client)
assert.False(t, view.hasDelegation)
assert.Equal(t, "", view.DelegationAllowAccess)
assert.Equal(t, "", view.DelegationDeviceBinding)
// Delegation rows must be omitted when no delegation is configured.
keyValues := view.KeyValues()
assert.Equal(t, [][]string{
{"CLIENT ID", "client-id"},
{"CAN CREATE TOKEN", boolean(true)},
{"ALLOWED METHODS", "cookie, query"},
{"DEVICE BINDING", "ip"},
}, keyValues)
}
func TestMakeSessionTransferView_WithDelegation(t *testing.T) {
client := &management.Client{
ClientID: auth0.String("client-id"),
SessionTransfer: &management.SessionTransfer{
CanCreateSessionTransferToken: auth0.Bool(true),
AllowedAuthenticationMethods: &[]string{"cookie"},
EnforceDeviceBinding: auth0.String("ip"),
Delegation: &management.SessionTransferDelegation{
AllowDelegatedAccess: auth0.Bool(true),
EnforceDeviceBinding: auth0.String("asn"),
},
},
}
view := MakeSessionTransferView(client)
assert.True(t, view.hasDelegation)
assert.Equal(t, boolean(true), view.DelegationAllowAccess)
assert.Equal(t, "asn", view.DelegationDeviceBinding)
// Delegation rows must be appended after the base session-transfer rows.
keyValues := view.KeyValues()
assert.Equal(t, [][]string{
{"CLIENT ID", "client-id"},
{"CAN CREATE TOKEN", boolean(true)},
{"ALLOWED METHODS", "cookie"},
{"DEVICE BINDING", "ip"},
{"ALLOW DELEGATED ACCESS", boolean(true)},
{"DELEGATION DEVICE BINDING", "asn"},
}, keyValues)
}