Skip to content

Commit

Permalink
Merge pull request #7 from form3tech-oss/ng/maintenance
Browse files Browse the repository at this point in the history
chore: change update tests & improve release process
  • Loading branch information
norberto-garcia-form3 authored Sep 4, 2024
2 parents 4696f69 + 3e3cd15 commit 48bff9a
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 45 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: CI
on:
push:
pull_request:
types:
- synchronize
- opened
- reopened
push:
branches:
- master

permissions:
contents: read
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: golangci-lint
on:
push:
pull_request:
types:
- synchronize
- opened
- reopened
push:
branches:
- master

permissions:
contents: read
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
name: release
on:
push:
branches:
- master
tags:
- v*.*.*
- "v*.*.*"

permissions:
contents: write

jobs:
publish:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Setup Golang
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod

- name: Go releaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
Expand Down
14 changes: 7 additions & 7 deletions chronicle/provider_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package chronicle

import (
"math/rand"
"strings"
"testing"

chronicle "github.com/form3tech-oss/terraform-provider-chronicle/client"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -37,11 +37,11 @@ func testAccPreCheck(t *testing.T) {
}

func randString(length int) string {
result := make([]byte, length)
set := "abcdefghijklmnopqrstuvwxyz012346789"
for i := 0; i < length; i++ {
//nolint:all
result[i] = set[rand.Intn(len(set))]
id := uuid.New().String()

if len(id) > length {
id = id[:length]
}
return string(result)

return id
}
9 changes: 6 additions & 3 deletions chronicle/resource_feed_amazon_s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func TestAccChronicleFeedAmazonS3_Basic(t *testing.T) {

func TestAccChronicleFeedAmazonS3_UpdateAuth(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
enabled := "true"
namespace := "test"
Expand Down Expand Up @@ -79,7 +80,7 @@ func TestAccChronicleFeedAmazonS3_UpdateAuth(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAmazonS3(displayName, logType, enabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region1, accesKeyID1, secretAccessKey1),
Config: testAccCheckChronicleFeedAmazonS3(displayName1, logType, enabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region1, accesKeyID1, secretAccessKey1),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAmazonS3Exists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
Expand All @@ -101,6 +102,7 @@ func TestAccChronicleFeedAmazonS3_UpdateAuth(t *testing.T) {

func TestAccChronicleFeedAmazonS3_UpdateEnabled(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
enabled := "true"
notEnabled := "false"
Expand Down Expand Up @@ -129,7 +131,7 @@ func TestAccChronicleFeedAmazonS3_UpdateEnabled(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAmazonS3(displayName, logType, notEnabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region, accesKeyID, secretAccessKey),
Config: testAccCheckChronicleFeedAmazonS3(displayName1, logType, notEnabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region, accesKeyID, secretAccessKey),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAmazonS3Exists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
Expand All @@ -150,6 +152,7 @@ func TestAccChronicleFeedAmazonS3_UpdateEnabled(t *testing.T) {

func TestAccChronicleFeedAmazonS3_UpdateLogType(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
logType1 := "AWS_CLOUDTRAIL"
notEnabled := "false"
Expand Down Expand Up @@ -178,7 +181,7 @@ func TestAccChronicleFeedAmazonS3_UpdateLogType(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAmazonS3(displayName, logType1, notEnabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region, accesKeyID, secretAccessKey),
Config: testAccCheckChronicleFeedAmazonS3(displayName1, logType1, notEnabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region, accesKeyID, secretAccessKey),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAmazonS3Exists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType1),
Expand Down
15 changes: 10 additions & 5 deletions chronicle/resource_feed_amazon_sqs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func TestAccChronicleFeedAmazonSQS_BasicWithS3Auth(t *testing.T) {

func TestAccChronicleFeedAmazonSQS_UpdateAuth(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
enabled := "true"
namespace := "test"
Expand Down Expand Up @@ -139,7 +140,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateAuth(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType, enabled, namespace, labels, queue, region1, accountNumber,
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType, enabled, namespace, labels, queue, region1, accountNumber,
sourceDeleteOptions, sqsAccesKeyID1, sqsSecretAccessKey1, s3AccesKeyID1, s3SecretAccessKey1),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAmazonSQSExists(rootRef),
Expand All @@ -162,6 +163,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateAuth(t *testing.T) {

func TestAccChronicleFeedAmazonSQS_UpdateEnabled(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
enabled := "true"
notEnabled := "false"
Expand Down Expand Up @@ -193,7 +195,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateEnabled(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType, notEnabled, namespace, labels, queue, region, accountNumber,
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType, notEnabled, namespace, labels, queue, region, accountNumber,
sourceDeleteOptions, sqsAccesKeyID, sqsSecretAccessKey, s3AccesKeyID, s3SecretAccessKey),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAmazonSQSExists(rootRef),
Expand All @@ -215,6 +217,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateEnabled(t *testing.T) {

func TestAccChronicleFeedAmazonSQS_UpdateLogType(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
logType1 := "AWS_CLOUDTRAIL"
notEnabled := "false"
Expand Down Expand Up @@ -246,7 +249,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateLogType(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType1, notEnabled, namespace, labels, queue, region, accountNumber,
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType1, notEnabled, namespace, labels, queue, region, accountNumber,
sourceDeleteOptions, sqsAccesKeyID, sqsSecretAccessKey, s3AccesKeyID, s3SecretAccessKey),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAmazonSQSExists(rootRef),
Expand All @@ -268,6 +271,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateLogType(t *testing.T) {

func TestAccChronicleFeedAmazonSQS_UpdateAccountNumber(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
notEnabled := "false"
namespace := "test"
Expand Down Expand Up @@ -300,7 +304,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateAccountNumber(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType, notEnabled, namespace, labels, queue, region, accountNumber1,
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType, notEnabled, namespace, labels, queue, region, accountNumber1,
sourceDeleteOptions, sqsAccesKeyID, sqsSecretAccessKey, s3AccesKeyID, s3SecretAccessKey),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAmazonSQSExists(rootRef),
Expand All @@ -323,6 +327,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateAccountNumber(t *testing.T) {

func TestAccChronicleFeedAmazonSQS_UpdateRegion(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
notEnabled := "false"
namespace := "test"
Expand Down Expand Up @@ -355,7 +360,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateRegion(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType, notEnabled, namespace, labels, queue, region1, accountNumber,
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType, notEnabled, namespace, labels, queue, region1, accountNumber,
sourceDeleteOptions, sqsAccesKeyID, sqsSecretAccessKey, s3AccesKeyID, s3SecretAccessKey),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAmazonSQSExists(rootRef),
Expand Down
9 changes: 6 additions & 3 deletions chronicle/resource_feed_azure_blobstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestAccChronicleFeedAzureBlobStore_Basic(t *testing.T) {

func TestAccChronicleFeedAzureBlobStore_UpdateAuth(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
enabled := "true"
namespace := "test"
Expand All @@ -73,7 +74,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateAuth(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAzureBlobStore(displayName, logType, enabled, namespace, labels, uri, sourceType, sharedKey1),
Config: testAccCheckChronicleFeedAzureBlobStore(displayName1, logType, enabled, namespace, labels, uri, sourceType, sharedKey1),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAzureBlobStoreExists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
Expand All @@ -97,6 +98,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateEnabled(t *testing.T) {
enabled := "true"
notEnabled := "false"
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "GITHUB"
namespace := "test"
labels := `"test"="test"`
Expand All @@ -121,7 +123,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateEnabled(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAzureBlobStore(displayName, logType, notEnabled, namespace, labels, uri, sourceType, sharedKey),
Config: testAccCheckChronicleFeedAzureBlobStore(displayName1, logType, notEnabled, namespace, labels, uri, sourceType, sharedKey),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAzureBlobStoreExists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
Expand All @@ -143,6 +145,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateEnabled(t *testing.T) {

func TestAccChronicleFeedAzureBlobStore_UpdateLogType(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
notEnabled := "false"
logType := "GITHUB"
logType1 := "AWS_CLOUDTRAIL"
Expand All @@ -168,7 +171,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateLogType(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedAzureBlobStore(displayName, logType1, notEnabled, namespace, labels, uri, sourceType, sharedKey),
Config: testAccCheckChronicleFeedAzureBlobStore(displayName1, logType1, notEnabled, namespace, labels, uri, sourceType, sharedKey),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedAzureBlobStoreExists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType1),
Expand Down
12 changes: 8 additions & 4 deletions chronicle/resource_feed_google_cloud_storage_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_Basic(t *testing.T) {

func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateBucketSourceType(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "ONEPASSWORD"
enabled := "true"
namespace := "test"
Expand Down Expand Up @@ -76,7 +77,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateBucketSourceType(t *test
),
},
{
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName, logType, enabled, namespace, labels, bucketUri, bucketSourceType1, sourceDeleteOptions),
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName1, logType, enabled, namespace, labels, bucketUri, bucketSourceType1, sourceDeleteOptions),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedGoogleCloudStorageBucketExists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
Expand All @@ -99,6 +100,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateBucketSourceType(t *test

func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateSourceDeletionOptions(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "ONEPASSWORD"
enabled := "true"
namespace := "test"
Expand Down Expand Up @@ -127,7 +129,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateSourceDeletionOptions(t
),
},
{
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName, logType, enabled, namespace, labels, bucketUri, bucketSourceType, sourceDeleteOptions1),
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName1, logType, enabled, namespace, labels, bucketUri, bucketSourceType, sourceDeleteOptions1),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedGoogleCloudStorageBucketExists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
Expand All @@ -150,6 +152,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateSourceDeletionOptions(t

func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateLogType(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "ONEPASSWORD"
logType1 := "AWS_CLOUDTRAIL"
enabled := "true"
Expand Down Expand Up @@ -178,7 +181,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateLogType(t *testing.T) {
),
},
{
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName, logType1, enabled, namespace, labels, bucketUri, bucketSourceType, sourceDeleteOptions),
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName1, logType1, enabled, namespace, labels, bucketUri, bucketSourceType, sourceDeleteOptions),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedGoogleCloudStorageBucketExists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType1),
Expand All @@ -201,6 +204,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateLogType(t *testing.T) {

func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateNamespace(t *testing.T) {
displayName := "test" + randString(10)
displayName1 := "test" + randString(10)
logType := "ONEPASSWORD"
enabled := "true"
namespace := "test"
Expand Down Expand Up @@ -229,7 +233,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateNamespace(t *testing.T)
),
},
{
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName, logType, enabled, namespace1, labels, bucketUri, bucketSourceType, sourceDeleteOptions),
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName1, logType, enabled, namespace1, labels, bucketUri, bucketSourceType, sourceDeleteOptions),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedGoogleCloudStorageBucketExists(rootRef),
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_Basic(t *testing.T

func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateAuth(t *testing.T) {
displayName := "testtf" + randString(10)
displayName1 := "testf" + randString(10)
enabled := "true"
namespace := "test"
labels := `"test"="test"`
Expand Down Expand Up @@ -80,7 +81,7 @@ func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateAuth(t *test
),
},
{
Config: testAccCheckChronicleFeedMicrosoftOffice365ManagementActivity(displayName, enabled, namespace, labels, hostname, tenantID, contentType, clientID1, clientSecret1),
Config: testAccCheckChronicleFeedMicrosoftOffice365ManagementActivity(displayName1, enabled, namespace, labels, hostname, tenantID, contentType, clientID1, clientSecret1),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedMicrosoftOffice365ManagementActivityExists(rootRef),
resource.TestCheckResourceAttr(rootRef, "enabled", enabled),
Expand All @@ -104,6 +105,7 @@ func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateAuth(t *test

func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateEnabled(t *testing.T) {
displayName := "testtf" + randString(10)
displayName1 := "testf" + randString(10)
enabled := "true"
notEnabled := "false"
namespace := "test"
Expand Down Expand Up @@ -133,7 +135,7 @@ func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateEnabled(t *t
),
},
{
Config: testAccCheckChronicleFeedMicrosoftOffice365ManagementActivity(displayName, notEnabled, namespace, labels, hostname, tenantID, contentType, clientID, clientSecret),
Config: testAccCheckChronicleFeedMicrosoftOffice365ManagementActivity(displayName1, notEnabled, namespace, labels, hostname, tenantID, contentType, clientID, clientSecret),
Check: resource.ComposeTestCheckFunc(
testAccCheckChronicleFeedMicrosoftOffice365ManagementActivityExists(rootRef),
resource.TestCheckResourceAttr(rootRef, "enabled", notEnabled),
Expand Down
Loading

0 comments on commit 48bff9a

Please sign in to comment.