Skip to content

Commit

Permalink
Fix: Acceptance Tests and CI Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr committed Apr 18, 2022
1 parent f07aa0f commit 4165c20
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 165 deletions.
7 changes: 1 addition & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod"
Expand All @@ -12,4 +7,4 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "weekly"
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# This GitHub action runs your tests for each commit push and/or PR. Optionally
# you can turn it on using a cron schedule for regular testing.
#
name: Acceptance Tests
name: CI
on:
pull_request:
push:
branches: [ master ]
paths-ignore:
- 'README.md'
- 'docs/**'
- 'cli/**'
push:

pull_request:
branches: [ master ]
paths-ignore:
- 'README.md'
- 'docs/**'
Expand All @@ -17,8 +20,10 @@ on:
# we recommend testing at a regular interval not necessarily tied to code changes. This will
# ensure you are alerted to something breaking due to an API change, even if the code did not
# change.
# schedule:
# - cron: '0 13 * * *'

schedule:
- cron: '0 13 * * *'

jobs:
# ensure the code builds...
build:
Expand All @@ -44,22 +49,10 @@ jobs:
run: |
go build -v .
# run acceptance tests in a matrix with Terraform core versions
# run acceptance tests
test:
# name: Matrix Test
needs: build
runs-on: ubuntu-latest
# timeout-minutes: 60
# strategy:
# fail-fast: false
# matrix:
# list whatever Terraform versions here you would like to support
# terraform:
# - '0.13.*'
# - '0.14.*'
# - '0.15.*'
# - '1.0.*'
# - '1.1.*'
steps:

- name: Set up Go
Expand All @@ -81,10 +74,8 @@ jobs:
go mod vendor && go mod tidy
- name: TF acceptance tests
# timeout-minutes: 60
env:
TF_ACC: "1"
# TESTARGS: -parallel 30
ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }}
ZIA_PASSWORD: ${{ secrets.ZIA_PASSWORD }}
ZIA_API_KEY: ${{ secrets.ZIA_API_KEY }}
Expand All @@ -100,4 +91,3 @@ jobs:
go build ./cli/ziaActivator.go
mv ziaActivator /usr/local/bin
ziaActivator
22 changes: 14 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# This GitHub action will publish assets for release when a tag is created
# that matches the pattern "v*" (ie. v0.1.0).
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
# Based on the configuration provided at:
# https://github.com/hashicorp/terraform-provider-scaffolding
name: Release

on:
push:
branches: [ master ]
tags:
- 'v*'

Expand All @@ -15,13 +21,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.17

Expand All @@ -39,4 +45,4 @@ jobs:
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78 changes: 0 additions & 78 deletions .github/workflows/test.yml

This file was deleted.

47 changes: 35 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 2.0.1 (April 17, 2022)

### Bug Fixes

Several schema type, expand and flattening function fixes were implemented to prevent undesired plan refresh updates and further provider optimization.

- ``zia_dlp_dictionaries`` - [PR#61](https://github.com/willguibr/terraform-provider-zia/pull/61) 🔧
- ``zia_dlp_web_rules`` - [PR#62](https://github.com/willguibr/terraform-provider-zia/pull/62) 🔧
- ``zia_firewall_filtering_rule`` - Added schema validation ``order`` parameter to ensure value is at least 1. [PR#63](https://github.com/willguibr/terraform-provider-zia/pull/63) 🔧
- ``zia_url_filtering_rules`` - [PR#66](https://github.com/willguibr/terraform-provider-zia/pull/66) 🔧
- ``zia_admin_users`` - [PR#67](https://github.com/willguibr/terraform-provider-zia/pull/67) 🔧
- ``zia_user_management`` - [PR#67](https://github.com/willguibr/terraform-provider-zia/pull/67) 🔧

### Enhancements

1. Updated ZIA API client to validate the corresponding Zscaler cloud name. The previous environment variable ``ZIA_BASE_URL`` was replaced with ``ZIA_CLOUD``. [PR#58](https://github.com/willguibr/terraform-provider-zia/pull/58)

2. The provider now validates the proper Zscaler cloud name. [PR#58](https://github.com/willguibr/terraform-provider-zia/pull/58) For instructions on how to find your Zscaler cloud name, refer to the following help article [Here](https://help.zscaler.com/zia/getting-started-zia-api#RetrieveAPIKey)

3. Added and fixed multiple acceptance tests to easily and routinely verify that Terraform Plugins produce the expected outcome

4. Updated GitHub Actions CI to include both build and acceptance test workflow

## 2.0.0 (February 9, 2022)

## New Resources and DataSources
Expand Down Expand Up @@ -40,18 +63,18 @@ UPDATES:

- The provider now supports the ability to import resources via its `name` and/or `id` property to support easier migration of existing ZIA resources via `terraform import` command.
The following resources are supported:
- resource_zia_admin_users - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47)] :rocket:
- resource_zia_dlp_dictionaries - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_firewall_filtering_rules - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_ip_destination_groups - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_ip_source_groups - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_network_application_groups - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_network_services_groups - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_network_services - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_location_management - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_url_categories - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_url_filtering_rules - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_user_management_users - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_admin_users - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47)] :rocket:
- resource_zia_dlp_dictionaries - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_firewall_filtering_rules - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_ip_destination_groups - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_ip_source_groups - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_network_application_groups - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_network_services_groups - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_fw_filtering_network_services - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_location_management - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_url_categories - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_url_filtering_rules - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:
- resource_zia_user_management_users - [PR#47](https://github.com/willguibr/terraform-provider-zia/pull/47) :rocket:

## 1.0.2 (November 29, 2021)

Expand Down
8 changes: 3 additions & 5 deletions zia/data_source_zia_admin_users_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package zia

/*
import (
"testing"

Expand All @@ -24,15 +23,14 @@ func TestAccDataSourceAdminUsers_Basic(t *testing.T) {
Config: testAccCheckAdminUsersConfigure(resourceTypeAndName, generatedName, rEmail, rPassword),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "id", resourceTypeAndName, "id"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "login_name", resourceTypeAndName, rEmail+"@securitygeek.io"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "email", resourceTypeAndName, rEmail+"@securitygeek.io"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "login_name", resourceTypeAndName, "login_name"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "email", resourceTypeAndName, "email"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "username", resourceTypeAndName, "username"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "password", resourceTypeAndName, rPassword+("Super@Secret007")),
// resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "password", resourceTypeAndName, rPassword+("Super@Secret007")),
resource.TestCheckResourceAttr(dataSourceTypeAndName, "role.#", "1"),
resource.TestCheckResourceAttr(dataSourceTypeAndName, "admin_scope.#", "1"),
),
},
},
})
}
*/
23 changes: 0 additions & 23 deletions zia/data_source_zia_user_management_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,32 +138,9 @@ func dataSourceUserManagementRead(d *schema.ResourceData, m interface{}) error {
if err := d.Set("department", flattenUserDepartment(resp.Department)); err != nil {
return err
}
// if err := d.Set("groups", flattenGroups(resp.Groups)); err != nil {
// return err
// }

// if err := d.Set("department", flattenDepartment(*resp.Department)); err != nil {
// return err
// }
} else {
return fmt.Errorf("couldn't find any user with name '%s' or id '%d'", name, id)
}

return nil
}

/*
func flattenDepartment(department *common.Department) []interface{} {
departments := make([]interface{}, 0)
if department != nil {
departments = append(departments, map[string]interface{}{
"id": department.ID,
"name": department.Name,
"idp_id": department.IdpID,
"comments": department.Comments,
"deleted": department.Deleted,
})
}
return departments
}
*/
10 changes: 4 additions & 6 deletions zia/data_source_zia_user_management_users_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package zia

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
Expand All @@ -25,11 +24,10 @@ func TestAccDataSourceUserManagement_Basic(t *testing.T) {
Config: testAccCheckUserManagementConfigure(resourceTypeAndName, generatedName, resourceTypeAndName, rEmail, rPassword, rComments),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "id", resourceTypeAndName, "id"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "name", resourceTypeAndName, fmt.Sprintf(rEmail+"@securitygeek.io")),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "email", resourceTypeAndName, fmt.Sprintf(rEmail+"@securitygeek.io")),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "comments", resourceTypeAndName, fmt.Sprintf(rComments+"tf-acc-test")),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "password", resourceTypeAndName, fmt.Sprintf(rPassword+"Super@Secret007")),
// resource.TestCheckResourceAttr(dataSourceTypeAndName, "groups.#", "2"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "name", resourceTypeAndName, "name"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "email", resourceTypeAndName, "email"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "comments", resourceTypeAndName, "comments"),
resource.TestCheckResourceAttr(dataSourceTypeAndName, "groups.#", "2"),
resource.TestCheckResourceAttr(dataSourceTypeAndName, "department.#", "1"),
),
},
Expand Down
8 changes: 4 additions & 4 deletions zia/resource_zia_admin_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ resource "%s" "%s" {
}
}
// data "%s" "%s" {
// id = "${%s.id}"
// }
data "%s" "%s" {
id = "${%s.id}"
}
`,
Expand All @@ -148,7 +148,7 @@ resource "%s" "%s" {

// data source variables
resourcetype.AdminUsers,
rEmail,
generatedName,
resourceTypeAndName,
)
}
4 changes: 2 additions & 2 deletions zia/resource_zia_user_management_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestAccResourceUserManagementBasic(t *testing.T) {
resource.TestCheckResourceAttr(resourceTypeAndName, "email", fmt.Sprintf(rEmail+"@securitygeek.io")),
resource.TestCheckResourceAttr(resourceTypeAndName, "password", fmt.Sprintf(rPassword+"Super@Secret007")),
resource.TestCheckResourceAttr(resourceTypeAndName, "comments", rComments),
// resource.TestCheckResourceAttr(resourceTypeAndName, "groups.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "groups.#", "2"),
resource.TestCheckResourceAttr(resourceTypeAndName, "department.#", "1"),
),
},
Expand Down Expand Up @@ -145,7 +145,7 @@ data "%s" "%s" {

// data source variables
resourcetype.Users,
rEmail,
generatedName,
resourceTypeAndName,
)
}

0 comments on commit 4165c20

Please sign in to comment.