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

[v1] Add projectID to fwaas_v2 policy CreateOpts and ListOpts #2715

Merged
merged 1 commit into from
Aug 2, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ListOptsBuilder interface {
// and is either `asc' or `desc'. Marker and Limit are used for pagination.
type ListOpts struct {
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
Name string `q:"name"`
Description string `q:"description"`
Shared *bool `q:"shared"`
Expand Down Expand Up @@ -68,6 +69,7 @@ type CreateOpts struct {
// Only required if the caller has an admin role and wants to create a firewall policy
// for another tenant.
TenantID string `json:"tenant_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Shared *bool `json:"shared,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Policy struct {
Name string `json:"name"`
Description string `json:"description"`
TenantID string `json:"tenant_id"`
ProjectID string `json:"project_id"`
Audited bool `json:"audited"`
Shared bool `json:"shared"`
Rules []string `json:"firewall_rules,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestList(t *testing.T) {
"c9e77ca0-1bc8-497d-904d-948107873dc6"
],
"tenant_id": "9145d91459d248b1b02fdaca97c6a75d",
"project_id": "9145d91459d248b1b02fdaca97c6a75d",
"audited": true,
"shared": false,
"id": "f2b08c1e-aa81-4668-8ae1-1401bcb0576c",
Expand All @@ -44,6 +45,7 @@ func TestList(t *testing.T) {
"03d2a6ad-633f-431a-8463-4370d06a22c8"
],
"tenant_id": "9145d91459d248b1b02fdaca97c6a75d",
"project_id": "9145d91459d248b1b02fdaca97c6a75d",
"audited": false,
"shared": true,
"id": "c854fab5-bdaf-4a86-9359-78de93e5df01",
Expand Down Expand Up @@ -72,6 +74,7 @@ func TestList(t *testing.T) {
"c9e77ca0-1bc8-497d-904d-948107873dc6",
},
TenantID: "9145d91459d248b1b02fdaca97c6a75d",
ProjectID: "9145d91459d248b1b02fdaca97c6a75d",
Audited: true,
Shared: false,
ID: "f2b08c1e-aa81-4668-8ae1-1401bcb0576c",
Expand All @@ -83,6 +86,7 @@ func TestList(t *testing.T) {
"03d2a6ad-633f-431a-8463-4370d06a22c8",
},
TenantID: "9145d91459d248b1b02fdaca97c6a75d",
ProjectID: "9145d91459d248b1b02fdaca97c6a75d",
Audited: false,
Shared: true,
ID: "c854fab5-bdaf-4a86-9359-78de93e5df01",
Expand Down Expand Up @@ -119,6 +123,7 @@ func TestCreate(t *testing.T) {
],
"description": "Firewall policy",
"tenant_id": "9145d91459d248b1b02fdaca97c6a75d",
"project_id": "9145d91459d248b1b02fdaca97c6a75d",
"audited": true,
"shared": false
}
Expand All @@ -137,6 +142,7 @@ func TestCreate(t *testing.T) {
"11a58c87-76be-ae7c-a74e-b77fffb88a32"
],
"tenant_id": "9145d91459d248b1b02fdaca97c6a75d",
"project_id": "9145d91459d248b1b02fdaca97c6a75d",
"audited": false,
"id": "f2b08c1e-aa81-4668-8ae1-1401bcb0576c",
"description": "Firewall policy"
Expand All @@ -147,6 +153,7 @@ func TestCreate(t *testing.T) {

options := policies.CreateOpts{
TenantID: "9145d91459d248b1b02fdaca97c6a75d",
ProjectID: "9145d91459d248b1b02fdaca97c6a75d",
Name: "policy",
Description: "Firewall policy",
Shared: gophercloud.Disabled,
Expand Down Expand Up @@ -211,7 +218,7 @@ func TestInsertRule(t *testing.T) {
th.AssertEquals(t, "e3c78ab6-e827-4297-8d68-739063865a8b", policy.ID)
th.AssertEquals(t, "TESTACC-DESC-8P12aLfW", policy.Description)
th.AssertEquals(t, "9f98fc0e5f944cd1b51798b668dc8778", policy.TenantID)

th.AssertEquals(t, "9f98fc0e5f944cd1b51798b668dc8778", policy.ProjectID)
}

func TestInsertRuleWithInvalidParameters(t *testing.T) {
Expand Down Expand Up @@ -253,6 +260,7 @@ func TestGet(t *testing.T) {
"03d2a6ad-633f-431a-8463-4370d06a22c8"
],
"tenant_id": "9145d91459d248b1b02fdaca97c6a75d",
"project_id": "9145d91459d248b1b02fdaca97c6a75d",
"audited": false,
"id": "f2b08c1e-aa81-4668-8ae1-1401bcb0576c",
"description": "Firewall policy web"
Expand All @@ -272,6 +280,7 @@ func TestGet(t *testing.T) {
th.AssertEquals(t, "c9e77ca0-1bc8-497d-904d-948107873dc6", policy.Rules[1])
th.AssertEquals(t, "03d2a6ad-633f-431a-8463-4370d06a22c8", policy.Rules[2])
th.AssertEquals(t, "9145d91459d248b1b02fdaca97c6a75d", policy.TenantID)
th.AssertEquals(t, "9145d91459d248b1b02fdaca97c6a75d", policy.ProjectID)
}

func TestUpdate(t *testing.T) {
Expand Down Expand Up @@ -309,6 +318,7 @@ func TestUpdate(t *testing.T) {
"03d2a6ad-633f-431a-8463-4370d06a22c8"
],
"tenant_id": "9145d91459d248b1b02fdaca97c6a75d",
"project_id": "9145d91459d248b1b02fdaca97c6a75d",
"audited": false,
"id": "f2b08c1e-aa81-4668-8ae1-1401bcb0576c",
"description": "Firewall policy"
Expand Down
Loading