forked from GetStream/stream-chat-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_test.go
67 lines (55 loc) · 1.54 KB
/
app_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
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 stream_chat //nolint: golint
import (
"log"
"testing"
"github.com/stretchr/testify/require"
)
func TestClient_GetApp(t *testing.T) {
c := initClient(t)
_, err := c.GetAppConfig()
require.NoError(t, err)
}
func TestClient_UpdateAppSettings(t *testing.T) {
c := initClient(t)
settings := NewAppSettings().
SetDisableAuth(true).
SetDisablePermissions(true)
err := c.UpdateAppSettings(settings)
require.NoError(t, err)
}
// See https://getstream.io/chat/docs/app_settings_auth/ for
// more details.
func ExampleClient_UpdateAppSettings_disable_auth() {
client, err := NewClient("XXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
if err != nil {
log.Fatalf("Err: %v", err)
}
// disable auth checks, allows dev token usage
settings := NewAppSettings().SetDisableAuth(true)
err = client.UpdateAppSettings(settings)
if err != nil {
log.Fatalf("Err: %v", err)
}
// re-enable auth checks
err = client.UpdateAppSettings(NewAppSettings().SetDisableAuth(false))
if err != nil {
log.Fatalf("Err: %v", err)
}
}
func ExampleClient_UpdateAppSettings_disable_permission() {
client, err := NewClient("XXXX", "XXXX")
if err != nil {
log.Fatalf("Err: %v", err)
}
// disable permission checkse
settings := NewAppSettings().SetDisablePermissions(true)
err = client.UpdateAppSettings(settings)
if err != nil {
log.Fatalf("Err: %v", err)
}
// re-enable permission checks
err = client.UpdateAppSettings(NewAppSettings().SetDisablePermissions(false))
if err != nil {
log.Fatalf("Err: %v", err)
}
}