forked from cloudflare/cloudflare-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auditlogs: fix GetOrganizationAuditLogs() (cloudflare#415)
* auditlogs: fix GetOrganizationAuditLogs() Move to using stdlib strategies for encoding URL parameters. * Fix tests * Update godoc * auditlogs: use /accounts/${account_id}/audit_logs for audit logs `/organizations` has been deprecated. Pointed out by: @jacobbednarz * Update auditlogs_test.go Co-authored-by: Patryk Szczygłowski <[email protected]>
- Loading branch information
Showing
2 changed files
with
54 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,51 +5,51 @@ import ( | |
"testing" | ||
) | ||
|
||
func TestAuditLogFilterStringify(t *testing.T) { | ||
func TestAuditLogFilterToQuery(t *testing.T) { | ||
filter := AuditLogFilter{ | ||
ID: "aaaa", | ||
} | ||
if !strings.Contains(filter.String(), "&id=aaaa") { | ||
t.Fatalf("Did not properly stringify the id field: %s", filter.String()) | ||
if !strings.Contains(filter.ToQuery().Encode(), "id=aaaa") { | ||
t.Fatalf("Did not properly stringify the id field: %s", filter.ToQuery().Encode()) | ||
} | ||
|
||
filter.ActorIP = "1.1.1.1" | ||
if !strings.Contains(filter.String(), "&actor.ip=1.1.1.1") { | ||
t.Fatalf("Did not properly stringify the actorip field: %s", filter.String()) | ||
filter.ActorEmail = "[email protected]" | ||
if !strings.Contains(filter.ToQuery().Encode(), "actor.email=admin%40example.com") { | ||
t.Fatalf("Did not properly stringify the actor.email field: %s", filter.ToQuery().Encode()) | ||
} | ||
|
||
filter.ZoneName = "ejj.io" | ||
if !strings.Contains(filter.String(), "&zone.name=ejj.io") { | ||
t.Fatalf("Did not properly stringify the zone.name field: %s", filter.String()) | ||
filter.ActorIP = "192.0.2.0" | ||
if !strings.Contains(filter.ToQuery().Encode(), "&actor.ip=192.0.2.0") { | ||
t.Fatalf("Did not properly stringify the actorip field: %s", filter.ToQuery().Encode()) | ||
} | ||
|
||
filter.ActorEmail = "admin@admin.com" | ||
if !strings.Contains(filter.String(), "&actor.email=admin@admin.com") { | ||
t.Fatalf("Did not properly stringify the actor.email field: %s", filter.String()) | ||
filter.ZoneName = "example.com" | ||
if !strings.Contains(filter.ToQuery().Encode(), "&zone.name=example.com") { | ||
t.Fatalf("Did not properly stringify the zone.name field: %s", filter.ToQuery().Encode()) | ||
} | ||
|
||
filter.Direction = "direction" | ||
if !strings.Contains(filter.String(), "&direction=direction") { | ||
t.Fatalf("Did not properly stringify the direction field: %s", filter.String()) | ||
if !strings.Contains(filter.ToQuery().Encode(), "&direction=direction") { | ||
t.Fatalf("Did not properly stringify the direction field: %s", filter.ToQuery().Encode()) | ||
} | ||
|
||
filter.Since = "10-2-2018" | ||
if !strings.Contains(filter.String(), "&since=10-2-2018") { | ||
t.Fatalf("Did not properly stringify the since field: %s", filter.String()) | ||
if !strings.Contains(filter.ToQuery().Encode(), "&since=10-2-2018") { | ||
t.Fatalf("Did not properly stringify the since field: %s", filter.ToQuery().Encode()) | ||
} | ||
|
||
filter.Before = "10-2-2018" | ||
if !strings.Contains(filter.String(), "&before=10-2-2018") { | ||
t.Fatalf("Did not properly stringify the before field: %s", filter.String()) | ||
if !strings.Contains(filter.ToQuery().Encode(), "&before=10-2-2018") { | ||
t.Fatalf("Did not properly stringify the before field: %s", filter.ToQuery().Encode()) | ||
} | ||
|
||
filter.PerPage = 10000 | ||
if !strings.Contains(filter.String(), "&per_page=10000") { | ||
t.Fatalf("Did not properly stringify the per_page field: %s", filter.String()) | ||
if !strings.Contains(filter.ToQuery().Encode(), "&per_page=10000") { | ||
t.Fatalf("Did not properly stringify the per_page field: %s", filter.ToQuery().Encode()) | ||
} | ||
|
||
filter.Page = 3 | ||
if !strings.Contains(filter.String(), "&page=3") { | ||
t.Fatalf("Did not properly stringify the page field: %s", filter.String()) | ||
if !strings.Contains(filter.ToQuery().Encode(), "&page=3") { | ||
t.Fatalf("Did not properly stringify the page field: %s", filter.ToQuery().Encode()) | ||
} | ||
} |