-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclients_test.go
More file actions
57 lines (47 loc) · 1.12 KB
/
clients_test.go
File metadata and controls
57 lines (47 loc) · 1.12 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
package cwhydra_test
import (
"crypto/tls"
"log"
"net/http"
"testing"
"codeberg.org/coldwire/cwhydra"
)
func TestClient(t *testing.T) {
log.Println("Initializing API")
api := cwhydra.New(cwhydra.Config{
Url: "http://127.0.0.1:4445",
Http: http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
Timeout: 0,
},
})
log.Println("Creating a client named 'test'")
create, err := cwhydra.ClientManager(api).Create(cwhydra.OAuth2Client{
ClientName: "test",
})
if err != nil {
t.Error(err)
}
log.Println("> The client id is:", create.ClientId)
log.Println("Getting the created client")
g, err := cwhydra.ClientManager(api).Get(create.ClientId)
if err != nil {
t.Error(err)
}
log.Println(">", "Name of the client:", g.ClientName)
log.Println("List all clients")
clients, err := cwhydra.ClientManager(api).List()
if err != nil {
t.Error(err)
}
for i, v := range clients {
log.Println(">", i, v.ClientId)
}
log.Println("Deleting client:", create.ClientId)
err = cwhydra.ClientManager(api).Delete(create.ClientId)
if err != nil {
t.Error(err)
}
}