forked from cloudflare/cloudflare-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_user_tokens_test.go
56 lines (42 loc) · 1.33 KB
/
access_user_tokens_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
package cloudflare
import (
"context"
"fmt"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRevokeAccessUserTokens(t *testing.T) {
setup()
defer teardown()
handler := func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPost, r.Method, "Expected method 'POST', got %s", r.Method)
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, `{
"success": true,
"result": true
}
`)
}
mux.HandleFunc("/accounts/"+testAccountID+"/access/organizations/revoke_user", handler)
AccessUserEmail := AccessUserEmail{Email: "test@example.com"}
err := client.RevokeAccessUserTokens(context.Background(), testAccountID, AccessUserEmail)
assert.NoError(t, err)
}
func TestRevokeZoneLevelAccessUserTokens(t *testing.T) {
setup()
defer teardown()
handler := func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPost, r.Method, "Expected method 'POST', got %s", r.Method)
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, `{
"success": true,
"result": true
}
`)
}
mux.HandleFunc("/zones/"+testZoneID+"/access/organizations/revoke_user", handler)
AccessUserEmail := AccessUserEmail{Email: "test@example.com"}
err := client.RevokeZoneLevelAccessUserTokens(context.Background(), testZoneID, AccessUserEmail)
assert.NoError(t, err)
}