-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_test.go
92 lines (84 loc) · 2.96 KB
/
example_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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package xrhidgen_test
import (
"encoding/json"
"fmt"
"github.com/subpop/xrhidgen"
)
func ExampleAssociate() {
xrhidgen.SetSeed(100)
id, err := xrhidgen.NewAssociateIdentity(xrhidgen.Identity{}, xrhidgen.Associate{})
if err != nil {
panic(err)
}
data, err := json.Marshal(id)
if err != nil {
panic(err)
}
fmt.Println(string(data))
//Output: {"identity":{"employee_account_number":"02299","org_id":"41123","internal":{"org_id":""},"associate":{"Role":null,"email":"winnifredwinning@shred.org","givenName":"Cameron","rhatUUID":"00e3c758-1d7d-4ecd-98a2-997157e2d05c","surname":"Swift"},"type":"Associate","auth_type":"basic-auth"},"entitlements":null}
}
func ExampleInternal() {
xrhidgen.SetSeed(101)
id, err := xrhidgen.NewInternalIdentity(xrhidgen.Identity{}, xrhidgen.Internal{})
if err != nil {
panic(err)
}
data, err := json.Marshal(id)
if err != nil {
panic(err)
}
fmt.Println(string(data))
//Output: {"identity":{"org_id":"03797","internal":{"org_id":"08321","auth_time":-2978345600000000000},"type":"Internal","auth_type":"basic-auth"},"entitlements":null}
}
func ExampleSystem() {
xrhidgen.SetSeed(102)
id, err := xrhidgen.NewSystemIdentity(xrhidgen.Identity{}, xrhidgen.System{})
if err != nil {
panic(err)
}
data, err := json.Marshal(id)
if err != nil {
panic(err)
}
fmt.Println(string(data))
//Output: {"identity":{"account_number":"16398","org_id":"57572","internal":{"org_id":"57572"},"system":{"cn":"It6P","cert_type":"consumer","cluster_id":"x8LdjPo"},"type":"System","auth_type":"basic-auth"},"entitlements":null}
}
func ExampleUser() {
xrhidgen.SetSeed(103)
id, err := xrhidgen.NewUserIdentity(xrhidgen.Identity{}, xrhidgen.User{})
if err != nil {
panic(err)
}
data, err := json.Marshal(id)
if err != nil {
panic(err)
}
fmt.Println(string(data))
//Output: {"identity":{"org_id":"23807","internal":{"org_id":"23807"},"user":{"username":"tycoon","email":"fransen@crump.biz","first_name":"Frankie","last_name":"Collins","is_active":false,"is_org_admin":false,"is_internal":true,"locale":"pi","user_id":"backset"},"type":"User","auth_type":"cert-auth"},"entitlements":null}
}
func ExampleX509() {
xrhidgen.SetSeed(103)
id, err := xrhidgen.NewX509Identity(xrhidgen.Identity{}, xrhidgen.X509{})
if err != nil {
panic(err)
}
data, err := json.Marshal(id)
if err != nil {
panic(err)
}
fmt.Println(string(data))
//Output: {"identity":{"org_id":"23807","internal":{"org_id":""},"x509":{"subject_dn":"2","issuer_dn":"3sfSj"},"type":"X509","auth_type":"cert-auth"},"entitlements":null}
}
func ExampleServiceAccount() {
xrhidgen.SetSeed(103)
id, err := xrhidgen.NewServiceAccountIdentity(xrhidgen.Identity{}, xrhidgen.ServiceAccount{})
if err != nil {
panic(err)
}
data, err := json.Marshal(id)
if err != nil {
panic(err)
}
fmt.Println(string(data))
//Output: {"identity":{"org_id":"23807","internal":{"org_id":""},"service_account":{"client_id":"2","username":"crump"},"type":"ServiceAccount","auth_type":"cert-auth"},"entitlements":null}
}