Skip to content
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
12 changes: 11 additions & 1 deletion integrations/terraform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ endif
TERRAFORM_EXISTS := $(shell terraform -version 2>/dev/null | grep 'Terraform v1.')
CURRENT_ULIMIT := $(shell ulimit -n)

TEST_ARGS?=

.PHONY: test
test: install
ifndef TERRAFORM_EXISTS
Expand All @@ -117,7 +119,15 @@ ifeq ($(shell expr $(CURRENT_ULIMIT) \< 1024), 1)
@echo "ulimit -n is too low ($(CURRENT_ULIMIT)), please set ulimit -n 1024"
@exit -1
endif
TF_ACC=true go test ./test -v
go test ./testlib -v $(TEST_ARGS)

.PHONY: test-full
test-full: TEST_ARGS=--tags enterprisetests
test-full: test

.PHONY: test-ent
test-ent: TEST_ARGS=--tags enterprisetests -run 'TestTerraformEnterprise.*'
test-ent: test

.PHONY: apply
apply: install
Expand Down
100 changes: 98 additions & 2 deletions integrations/terraform/go.mod

Large diffs are not rendered by default.

269 changes: 253 additions & 16 deletions integrations/terraform/go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"context"
Expand All @@ -25,6 +25,7 @@ import (
"github.com/gravitational/trace"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/stretchr/testify/require"

"github.com/gravitational/teleport/api/client"
)
Expand Down Expand Up @@ -59,10 +60,12 @@ func (c *nextAuditDateComparer) TestNextAuditDateUnchanged(name string) resource
}
}

func (s *TerraformSuite) TestAccessList() {
if !s.teleportFeatures.GetAdvancedAccessWorkflows() {
s.T().Skip("Doesn't work in OSS version, requires AdvancedWorkflow")
}
func (s *TerraformSuiteEnterprise) TestAccessList() {
require.True(s.T(),
s.teleportFeatures.GetAdvancedAccessWorkflows(),
"Test requires Advanced Access Workflows",
)

checkAccessListDestroyed := func(state *terraform.State) error {
_, err := s.client.AccessListClient().GetAccessList(context.TODO(), "test")
if trace.IsNotFound(err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"context"
Expand All @@ -28,7 +28,7 @@ import (
"github.com/gravitational/teleport/api/types"
)

func (s *TerraformSuite) TestApp() {
func (s *TerraformSuiteOSS) TestApp() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down Expand Up @@ -74,7 +74,7 @@ func (s *TerraformSuite) TestApp() {
})
}

func (s *TerraformSuite) TestImportApp() {
func (s *TerraformSuiteOSS) TestImportApp() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down Expand Up @@ -125,7 +125,7 @@ func (s *TerraformSuite) TestImportApp() {
})
}

func (s *TerraformSuiteWithCache) TestAppWithCache() {
func (s *TerraformSuiteOSSWithCache) TestAppWithCache() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)
checkDestroyed := func(state *terraform.State) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"context"
Expand All @@ -27,7 +27,7 @@ import (
"github.com/gravitational/teleport/api/types"
)

func (s *TerraformSuite) TestAuthPreference() {
func (s *TerraformSuiteOSS) TestAuthPreference() {
name := "teleport_auth_preference.test"

resource.Test(s.T(), resource.TestCase{
Expand Down Expand Up @@ -62,7 +62,7 @@ func (s *TerraformSuite) TestAuthPreference() {
})
}

func (s *TerraformSuite) TestImportAuthPreference() {
func (s *TerraformSuiteOSS) TestImportAuthPreference() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down Expand Up @@ -112,7 +112,7 @@ func (s *TerraformSuite) TestImportAuthPreference() {
})
}

func (s *TerraformSuiteWithCache) TestAuthPreferenceAddLabel() {
func (s *TerraformSuiteOSSWithCache) TestAuthPreferenceAddLabel() {
name := "teleport_auth_preference.cluster_auth_preference"

resource.Test(s.T(), resource.TestCase{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"context"
Expand All @@ -24,7 +24,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func (s *TerraformSuite) TestBot() {
func (s *TerraformSuiteOSS) TestBot() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func (s *TerraformSuite) TestClusterMaintenanceConfig() {
func (s *TerraformSuiteOSS) TestClusterMaintenanceConfig() {
name := "teleport_cluster_maintenance_config.test"

resource.Test(s.T(), resource.TestCase{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"context"
Expand All @@ -27,7 +27,7 @@ import (
"github.com/gravitational/teleport/api/types"
)

func (s *TerraformSuite) TestClusterNetworkingConfig() {
func (s *TerraformSuiteOSS) TestClusterNetworkingConfig() {
name := "teleport_cluster_networking_config.test"

resource.Test(s.T(), resource.TestCase{
Expand Down Expand Up @@ -63,7 +63,7 @@ func (s *TerraformSuite) TestClusterNetworkingConfig() {
})
}

func (s *TerraformSuite) TestImportClusterNetworkingConfig() {
func (s *TerraformSuiteOSS) TestImportClusterNetworkingConfig() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"encoding/base64"
Expand All @@ -25,7 +25,7 @@ import (
"github.com/stretchr/testify/require"
)

func (s *TerraformSuite) TestConfigureAuthBase64() {
func (s *TerraformSuiteOSS) TestConfigureAuthBase64() {
name := "teleport_app.test_auth_b64"

key, err := os.ReadFile(s.teleportConfig.ClientKey)
Expand Down Expand Up @@ -63,7 +63,7 @@ provider "teleport" {
})
}

func (s *TerraformSuite) TestConfigureAuthFiles() {
func (s *TerraformSuiteOSS) TestConfigureAuthFiles() {
name := "teleport_app.test_auth_files"

providerConfigUsingAuthFiles := `
Expand All @@ -89,7 +89,7 @@ provider "teleport" {
})
}

func (s *TerraformSuite) TestConfigureIdentityFilePath() {
func (s *TerraformSuiteOSS) TestConfigureIdentityFilePath() {
name := "teleport_app.test"

providerConfigUsingAuthFiles := `
Expand All @@ -113,7 +113,7 @@ provider "teleport" {
})
}

func (s *TerraformSuite) TestConfigureIdentityFileBase64() {
func (s *TerraformSuiteOSS) TestConfigureIdentityFileBase64() {
name := "teleport_app.test"

identity, err := os.ReadFile(s.teleportConfig.Identity)
Expand Down Expand Up @@ -141,7 +141,7 @@ provider "teleport" {
})
}

func (s *TerraformSuite) TestConfigureIdentityFileBase64_InvalidBase64() {
func (s *TerraformSuiteOSS) TestConfigureIdentityFileBase64_InvalidBase64() {
identityAsB64 := base64.StdEncoding.EncodeToString([]byte("invalid"))

providerConfigUsingAuthFiles := `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"context"
Expand All @@ -28,7 +28,7 @@ import (
"github.com/gravitational/teleport/api/types"
)

func (s *TerraformSuite) TestDatabase() {
func (s *TerraformSuiteOSS) TestDatabase() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down Expand Up @@ -77,7 +77,7 @@ func (s *TerraformSuite) TestDatabase() {
})
}

func (s *TerraformSuite) TestImportDatabase() {
func (s *TerraformSuiteOSS) TestImportDatabase() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"context"
Expand All @@ -23,15 +23,18 @@ import (
"github.com/gravitational/trace"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/stretchr/testify/require"

// devicepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/devicetrust/v1"
"github.com/gravitational/teleport/api/types"
)

func (s *TerraformSuite) TestTrustedDevices() {
if !s.teleportFeatures.GetDeviceTrust().GetEnabled() {
s.T().Skip("Doesn't work in OSS version, requires Device Trust")
}
func (s *TerraformSuiteEnterprise) TestTrustedDevices() {
require.True(s.T(),
s.teleportFeatures.GetDeviceTrust().GetEnabled(),
"Test requires Device Trust",
)

ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down Expand Up @@ -88,10 +91,12 @@ func (s *TerraformSuite) TestTrustedDevices() {
})
}

func (s *TerraformSuite) TestImportTrustedDevices() {
if !s.teleportFeatures.GetDeviceTrust().GetEnabled() {
s.T().Skip("Doesn't work in OSS version, requires Device Trust")
}
func (s *TerraformSuiteEnterprise) TestImportTrustedDevices() {
require.True(s.T(),
s.teleportFeatures.GetDeviceTrust().GetEnabled(),
"Test requires Device Trust",
)

ctx := context.Background()

r := "teleport_trusted_device"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package testlib

import (
"context"
Expand All @@ -28,7 +28,7 @@ import (
"github.com/gravitational/teleport/api/types"
)

func (s *TerraformSuite) TestGithubConnector() {
func (s *TerraformSuiteOSS) TestGithubConnector() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down Expand Up @@ -81,7 +81,7 @@ func (s *TerraformSuite) TestGithubConnector() {
})
}

func (s *TerraformSuite) TestImportGithubConnector() {
func (s *TerraformSuiteOSS) TestImportGithubConnector() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down Expand Up @@ -134,7 +134,7 @@ func (s *TerraformSuite) TestImportGithubConnector() {
})
}

func (s *TerraformSuite) TestGithubConnectorTeamsToRoles() {
func (s *TerraformSuiteOSS) TestGithubConnectorTeamsToRoles() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down Expand Up @@ -172,7 +172,7 @@ func (s *TerraformSuite) TestGithubConnectorTeamsToRoles() {
})
}

func (s *TerraformSuite) TestGithubConnectorWithoutMapping() {
func (s *TerraformSuiteOSS) TestGithubConnectorWithoutMapping() {
ctx, cancel := context.WithCancel(context.Background())
s.T().Cleanup(cancel)

Expand Down
Loading