-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing data\resource registry for missing parameters in new aqua vers…
…ions fixing tests to support both SAAS\ on prem environments Removing static contents from tests setting init function to support only one token req for all tests.
- Loading branch information
1 parent
e150488
commit 5e32288
Showing
26 changed files
with
410 additions
and
111 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
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
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package aquasec | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
) | ||
|
||
func TestAquasecUserSaasManagementDatasource(t *testing.T) { | ||
|
||
if !isSaasEnv() { | ||
t.Skip("Skipping saas user test because its on prem env") | ||
} | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckAquasecUserSaasDataSource(), | ||
Check: testAccCheckAquasecUsersSaasDataSourceExists("data.aquasec_users_saas.testusers"), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAquasecUserSaasDataSource() string { | ||
return ` | ||
data "aquasec_users_saas" "testusers" {} | ||
` | ||
} | ||
|
||
func testAccCheckAquasecUsersSaasDataSourceExists(n string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
rs, ok := s.RootModule().Resources[n] | ||
|
||
if !ok { | ||
return NewNotFoundErrorf("%s in state", n) | ||
} | ||
|
||
if rs.Primary.ID == "" { | ||
return NewNotFoundErrorf("Id for %s in state", n) | ||
} | ||
|
||
return nil | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package aquasec | ||
|
||
import ( | ||
"github.com/aquasecurity/terraform-provider-aquasec/client" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
func init() { | ||
log.Println("setup suite") | ||
var ( | ||
present, verifyTLS bool | ||
username, password, aquaURL, verifyTLSString, caCertPath string | ||
err error | ||
caCertByte []byte | ||
) | ||
|
||
username, present = os.LookupEnv("AQUA_USER") | ||
if !present { | ||
panic("AQUA_USER env is missing, please set it") | ||
} | ||
|
||
password, present = os.LookupEnv("AQUA_PASSWORD") | ||
if !present { | ||
panic("AQUA_PASSWORD env is missing, please set it") | ||
} | ||
|
||
aquaURL, present = os.LookupEnv("AQUA_URL") | ||
if !present { | ||
panic("AQUA_URL env is missing, please set it") | ||
} | ||
|
||
verifyTLSString, present = os.LookupEnv("AQUA_TLS_VERIFY") | ||
if !present { | ||
verifyTLSString = "true" | ||
} | ||
|
||
caCertPath, present = os.LookupEnv("AQUA_CA_CERT_PATH") | ||
if present { | ||
if caCertPath != "" { | ||
caCertByte, err = ioutil.ReadFile(caCertPath) | ||
if err != nil { | ||
panic("Unable to read CA certificates") | ||
} | ||
} | ||
panic("AQUA_CA_CERT_PATH env is missing, please set it") | ||
} | ||
|
||
verifyTLS, _ = strconv.ParseBool(verifyTLSString) | ||
|
||
aquaClient := client.NewClient(aquaURL, username, password, verifyTLS, caCertByte) | ||
token, url, _ := aquaClient.GetAuthToken() | ||
|
||
err = os.Setenv("TESTING_AUTH_TOKEN", token) | ||
if err != nil { | ||
panic("Failed to set AUTH_TOKEN env") | ||
} | ||
|
||
err = os.Setenv("TESTING_URL", url) | ||
if err != nil { | ||
panic("Failed to set TESTING_URL env") | ||
} | ||
log.Println("Finished to set token") | ||
|
||
} |
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
Oops, something went wrong.