Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from bool to Compatibool for ACL entries #307

Merged
merged 1 commit into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions fastly/acl_entries_batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ func TestClient_BatchModifyAclEntries_Create(t *testing.T) {
Operation: CreateBatchOperation,
IP: String("127.0.0.1"),
Subnet: Int(24),
Negated: Bool(false),
Negated: CBool(false),
Comment: String("ACL Entry 1"),
},
{
Operation: CreateBatchOperation,
IP: String("192.168.0.1"),
Subnet: Int(24),
Negated: Bool(false),
Negated: CBool(true),
Comment: String("ACL Entry 2"),
},
},
Expand All @@ -43,7 +43,6 @@ func TestClient_BatchModifyAclEntries_Create(t *testing.T) {
// When: I execute the batch create operations against the Fastly API,
var err error
record(t, fixtureBase+"create_acl_entries", func(c *Client) {

err = c.BatchModifyACLEntries(batchCreateOperations)
})
if err != nil {
Expand Down Expand Up @@ -89,9 +88,9 @@ func TestClient_BatchModifyAclEntries_Create(t *testing.T) {
}

actualNegated := entry.Negated
expectedNegated := batchCreateOperations.Entries[i].Negated
expectedNegated := bool(*batchCreateOperations.Entries[i].Negated)

if actualNegated != *expectedNegated {
if actualNegated != expectedNegated {
t.Errorf("Negated did not match, expected %v, got %v", expectedNegated, actualNegated)
}

Expand Down Expand Up @@ -127,14 +126,14 @@ func TestClient_BatchModifyAclEntries_Delete(t *testing.T) {
Operation: CreateBatchOperation,
IP: String("127.0.0.1"),
Subnet: Int(24),
Negated: Bool(false),
Negated: CBool(false),
Comment: String("ACL Entry 1"),
},
{
Operation: CreateBatchOperation,
IP: String("192.168.0.1"),
Subnet: Int(24),
Negated: Bool(false),
Negated: CBool(true),
Comment: String("ACL Entry 2"),
},
},
Expand Down Expand Up @@ -229,14 +228,14 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) {
Operation: CreateBatchOperation,
IP: String("127.0.0.1"),
Subnet: Int(24),
Negated: Bool(false),
Negated: CBool(false),
Comment: String("ACL Entry 1"),
},
{
Operation: CreateBatchOperation,
IP: String("192.168.0.1"),
Subnet: Int(24),
Negated: Bool(false),
Negated: CBool(true),
Comment: String("ACL Entry 2"),
},
},
Expand Down Expand Up @@ -276,7 +275,7 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) {
ID: String(createdACLEntries[0].ID),
IP: String("127.0.0.2"),
Subnet: Int(16),
Negated: Bool(true),
Negated: CBool(true),
Comment: String("Updated ACL Entry 1"),
},
},
Expand Down Expand Up @@ -334,9 +333,9 @@ func TestClient_BatchModifyAclEntries_Update(t *testing.T) {
}

actualNegated := actualACLEntries[0].Negated
expectedNegated := batchUpdateOperations.Entries[0].Negated
expectedNegated := bool(*batchUpdateOperations.Entries[0].Negated)

if actualNegated != *expectedNegated {
if actualNegated != expectedNegated {
t.Errorf("First Subnet did not match, expected %v, got %v", expectedNegated, actualNegated)
}

Expand Down
16 changes: 8 additions & 8 deletions fastly/acl_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ type CreateACLEntryInput struct {
IP string `form:"ip"`

// Optional fields
Subnet int `form:"subnet,omitempty"`
Negated bool `form:"negated,omitempty"`
Comment string `form:"comment,omitempty"`
Subnet int `form:"subnet,omitempty"`
Negated Compatibool `form:"negated,omitempty"`
Comment string `form:"comment,omitempty"`
}

// CreateACLEntry creates and returns a new ACL entry.
Expand Down Expand Up @@ -190,10 +190,10 @@ type UpdateACLEntryInput struct {
ID string

// Optional fields
IP *string `form:"ip,omitempty"`
Subnet *int `form:"subnet,omitempty"`
Negated *bool `form:"negated,omitempty"`
Comment *string `form:"comment,omitempty"`
IP *string `form:"ip,omitempty"`
Subnet *int `form:"subnet,omitempty"`
Negated *Compatibool `form:"negated,omitempty"`
Comment *string `form:"comment,omitempty"`
}

// UpdateACLEntry updates an ACL entry
Expand Down Expand Up @@ -237,7 +237,7 @@ type BatchACLEntry struct {
ID *string `json:"id,omitempty"`
IP *string `json:"ip,omitempty"`
Subnet *int `json:"subnet,omitempty"`
Negated *bool `json:"negated,omitempty"`
Negated *Compatibool `json:"negated,omitempty"`
Comment *string `json:"comment,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions fastly/acl_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestClient_ACLEntries(t *testing.T) {
ACLID: testACL.ID,
IP: "10.0.0.3",
Subnet: 8,
Negated: false,
Negated: Compatibool(false),
Comment: "test entry",
})
})
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestClient_ACLEntries(t *testing.T) {
ACLID: testACL.ID,
ID: e.ID,
IP: String("10.0.0.4"),
Negated: Bool(true),
Negated: CBool(true),
})
})
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions fastly/fixtures/acl_entries/acl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
version: 1
interactions:
- request:
body: ServiceID=5BEXGVZPrhtk8TJfJJiz5u&ServiceVersion=2&name=test_acl_ACLEntries
body: ServiceID=7i6HN3TK9wS159v2gPAZ8A&ServiceVersion=2&name=test_acl_ACLEntries
form:
ServiceID:
- 5BEXGVZPrhtk8TJfJJiz5u
- 7i6HN3TK9wS159v2gPAZ8A
ServiceVersion:
- "2"
name:
Expand All @@ -14,24 +14,24 @@ interactions:
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
url: https://api.fastly.com/service/5BEXGVZPrhtk8TJfJJiz5u/version/2/acl
- FastlyGo/4.0.0 (+github.com/fastly/go-fastly; go1.17)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/acl
method: POST
response:
body: '{"service_id":"5BEXGVZPrhtk8TJfJJiz5u","version":"2","name":"test_acl_ACLEntries","created_at":"2021-01-14T10:23:48Z","id":"3XA9Zoz75yiYlgnjzDAFmI","updated_at":"2021-01-14T10:23:48Z","deleted_at":null}'
body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"2","name":"test_acl_ACLEntries","updated_at":"2021-09-22T10:29:24Z","deleted_at":null,"id":"1PCB9fTlFSnrOrUCKa0WzO","created_at":"2021-09-22T10:29:24Z"}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-cache
- no-store
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:23:48 GMT
- Wed, 22 Sep 2021 10:29:24 GMT
Fastly-Ratelimit-Remaining:
- "977"
- "4994"
Fastly-Ratelimit-Reset:
- "1610622000"
- "1632308400"
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -45,9 +45,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9036-CONTROL-SLWDC, cache-man4136-MAN
- cache-control-slwdc9035-CONTROL-SLWDC, cache-man4130-MAN
X-Timer:
- S1610619828.969284,VS0,VE303
- S1632306565.759753,VS0,VE215
status: 200 OK
code: 200
duration: ""
26 changes: 13 additions & 13 deletions fastly/fixtures/acl_entries/create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
version: 1
interactions:
- request:
body: ACLID=3XA9Zoz75yiYlgnjzDAFmI&ServiceID=5BEXGVZPrhtk8TJfJJiz5u&comment=test+entry&ip=10.0.0.3&subnet=8
body: ACLID=1PCB9fTlFSnrOrUCKa0WzO&ServiceID=7i6HN3TK9wS159v2gPAZ8A&comment=test+entry&ip=10.0.0.3&subnet=8
form:
ACLID:
- 3XA9Zoz75yiYlgnjzDAFmI
- 1PCB9fTlFSnrOrUCKa0WzO
ServiceID:
- 5BEXGVZPrhtk8TJfJJiz5u
- 7i6HN3TK9wS159v2gPAZ8A
comment:
- test entry
ip:
Expand All @@ -18,25 +18,25 @@ interactions:
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
url: https://api.fastly.com/service/5BEXGVZPrhtk8TJfJJiz5u/acl/3XA9Zoz75yiYlgnjzDAFmI/entry
- FastlyGo/4.0.0 (+github.com/fastly/go-fastly; go1.17)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/acl/1PCB9fTlFSnrOrUCKa0WzO/entry
method: POST
response:
body: '{"service_id":"5BEXGVZPrhtk8TJfJJiz5u","acl_id":"3XA9Zoz75yiYlgnjzDAFmI","ip":"10.0.0.3","subnet":8,"comment":"test
entry","id":"5Eyk2g71nkTniNmscr6bJs","updated_at":"2021-01-14T10:23:48Z","created_at":"2021-01-14T10:23:48Z","negated":0,"deleted_at":null}'
body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","acl_id":"1PCB9fTlFSnrOrUCKa0WzO","ip":"10.0.0.3","subnet":8,"comment":"test
entry","negated":0,"updated_at":"2021-09-22T10:29:25Z","created_at":"2021-09-22T10:29:25Z","id":"69nI3MhHVzdtXD5XW9B6ZN"}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-cache
- no-store
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:23:48 GMT
- Wed, 22 Sep 2021 10:29:25 GMT
Fastly-Ratelimit-Remaining:
- "976"
- "4993"
Fastly-Ratelimit-Reset:
- "1610622000"
- "1632308400"
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -50,9 +50,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9035-CONTROL-SLWDC, cache-man4136-MAN
- cache-control-slwdc9037-CONTROL-SLWDC, cache-man4130-MAN
X-Timer:
- S1610619828.394394,VS0,VE252
- S1632306565.999302,VS0,VE170
status: 200 OK
code: 200
duration: ""
16 changes: 8 additions & 8 deletions fastly/fixtures/acl_entries/create_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ interactions:
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
- FastlyGo/4.0.0 (+github.com/fastly/go-fastly; go1.17)
url: https://api.fastly.com/service
method: POST
response:
body: '{"customer_id":"51MumwLiSJyFTWhtbByYgR","comment":"go-fastly client test","name":"test_service_ACLEntries","type":"vcl","id":"5BEXGVZPrhtk8TJfJJiz5u","paused":false,"versions":[{"deployed":false,"staging":false,"locked":false,"service_id":"5BEXGVZPrhtk8TJfJJiz5u","created_at":"2021-01-14T10:23:47Z","testing":false,"updated_at":"2021-01-14T10:23:47Z","active":false,"comment":"","number":1,"deleted_at":null}],"updated_at":"2021-01-14T10:23:47Z","created_at":"2021-01-14T10:23:47Z","deleted_at":null,"publish_key":""}'
body: '{"customer_id":"51MumwLiSJyFTWhtbByYgR","comment":"go-fastly client test","name":"test_service_ACLEntries","type":"vcl","id":"7i6HN3TK9wS159v2gPAZ8A","updated_at":"2021-09-22T10:29:24Z","versions":[{"service_id":"7i6HN3TK9wS159v2gPAZ8A","updated_at":"2021-09-22T10:29:24Z","staging":false,"comment":"","deployed":false,"locked":false,"deleted_at":null,"testing":false,"number":1,"active":false,"created_at":"2021-09-22T10:29:24Z"}],"paused":false,"publish_key":"","created_at":"2021-09-22T10:29:24Z","deleted_at":null}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-cache
- no-store
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:23:47 GMT
- Wed, 22 Sep 2021 10:29:24 GMT
Fastly-Ratelimit-Remaining:
- "979"
- "4996"
Fastly-Ratelimit-Reset:
- "1610622000"
- "1632308400"
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -45,9 +45,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9037-CONTROL-SLWDC, cache-man4136-MAN
- cache-control-slwdc9037-CONTROL-SLWDC, cache-man4130-MAN
X-Timer:
- S1610619827.274502,VS0,VE238
- S1632306564.308192,VS0,VE206
status: 200 OK
code: 200
duration: ""
16 changes: 8 additions & 8 deletions fastly/fixtures/acl_entries/delete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ interactions:
form: {}
headers:
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
url: https://api.fastly.com/service/5BEXGVZPrhtk8TJfJJiz5u/acl/3XA9Zoz75yiYlgnjzDAFmI/entry/5Eyk2g71nkTniNmscr6bJs
- FastlyGo/4.0.0 (+github.com/fastly/go-fastly; go1.17)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/acl/1PCB9fTlFSnrOrUCKa0WzO/entry/69nI3MhHVzdtXD5XW9B6ZN
method: DELETE
response:
body: '{"status":"ok"}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-cache
- no-store
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:23:50 GMT
- Wed, 22 Sep 2021 10:29:26 GMT
Fastly-Ratelimit-Remaining:
- "974"
- "4991"
Fastly-Ratelimit-Reset:
- "1610622000"
- "1632308400"
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -37,9 +37,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9035-CONTROL-SLWDC, cache-man4136-MAN
- cache-control-slwdc9035-CONTROL-SLWDC, cache-man4130-MAN
X-Timer:
- S1610619830.037578,VS0,VE264
- S1632306566.833539,VS0,VE209
status: 200 OK
code: 200
duration: ""
16 changes: 8 additions & 8 deletions fastly/fixtures/acl_entries/delete_acl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ interactions:
form: {}
headers:
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
url: https://api.fastly.com/service/5BEXGVZPrhtk8TJfJJiz5u/version/2/acl/test_acl_ACLEntries
- FastlyGo/4.0.0 (+github.com/fastly/go-fastly; go1.17)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/2/acl/test_acl_ACLEntries
method: DELETE
response:
body: '{"status":"ok"}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-cache
- no-store
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:23:50 GMT
- Wed, 22 Sep 2021 10:29:26 GMT
Fastly-Ratelimit-Remaining:
- "973"
- "4990"
Fastly-Ratelimit-Reset:
- "1610622000"
- "1632308400"
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -37,9 +37,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9036-CONTROL-SLWDC, cache-man4136-MAN
- cache-control-slwdc9036-CONTROL-SLWDC, cache-man4130-MAN
X-Timer:
- S1610619830.345719,VS0,VE313
- S1632306566.062229,VS0,VE229
status: 200 OK
code: 200
duration: ""
Loading