<commit_before>package provisioning

import (
	"testing"

	"github.com/rancher/rancher/tests/framework/clients/rancher"
	management "github.com/rancher/rancher/tests/framework/clients/rancher/generated/management/v3"
	"github.com/rancher/rancher/tests/framework/extensions/cloudcredentials/aws"
	"github.com/rancher/rancher/tests/framework/extensions/clusters"
	"github.com/rancher/rancher/tests/framework/extensions/clusters/eks"
	"github.com/rancher/rancher/tests/framework/extensions/users"
	"github.com/rancher/rancher/tests/framework/pkg/session"
	"github.com/rancher/rancher/tests/framework/pkg/wait"
	"github.com/rancher/rancher/tests/integration/pkg/defaults"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"github.com/stretchr/testify/suite"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type HostesdClusterProvisioningTestSuite struct {
	suite.Suite
	client             *rancher.Client
	session            *session.Session
	standardUserClient *rancher.Client
}

func (h *HostesdClusterProvisioningTestSuite) TearDownSuite() {
	h.session.Cleanup()
}

func (h *HostesdClusterProvisioningTestSuite) SetupSuite() {
	testSession := session.NewSession(h.T())
	h.session = testSession

	client, err := rancher.NewClient("", testSession)
	require.NoError(h.T(), err)

	h.client = client

	enabled := true
	var testuser = AppendRandomString("testuser-")
	user := &management.User{
		Username: testuser,
		Password: "<PASSWORD>!",
		Name:     testuser,
		Enabled:  &enabled,
	}

	newUser, err := users.CreateUserWithRole(client, user, "user")
	require.NoError(h.T(), err)

	newUser.Password = <PASSWORD>.Password

	standardUserClient, err := client.AsUser(newUser)
	require.NoError(h.T(), err)

	h.standardUserClient = standardUserClient
}

func (h *HostesdClusterProvisioningTestSuite) TestProvisioningHostedEKSCluster() {
	tests := []struct {
		name   string
		client *rancher.Client
	}{
		{"Admin User", h.client},
		{"Standard User", h.standardUserClient},
	}

	for _, tt := range tests {
		h.Run(tt.name, func() {
			subSession := h.session.NewSession()
			defer subSession.Cleanup()

			client, err := tt.client.WithSession(subSession)<commit_msg>Implemented simple AKS validation test.<commit_after>package provisioning

import (
	"testing"

	"github.com/rancher/rancher/tests/framework/clients/rancher"
	management "github.com/rancher/rancher/tests/framework/clients/rancher/generated/management/v3"
	"github.com/rancher/rancher/tests/framework/extensions/cloudcredentials/aws"
	"github.com/rancher/rancher/tests/framework/extensions/cloudcredentials/azure"
	"github.com/rancher/rancher/tests/framework/extensions/clusters"
	"github.com/rancher/rancher/tests/framework/extensions/clusters/aks"
	"github.com/rancher/rancher/tests/framework/extensions/clusters/eks"
	"github.com/rancher/rancher/tests/framework/extensions/users"
	"github.com/rancher/rancher/tests/framework/pkg/session"
	"github.com/rancher/rancher/tests/framework/pkg/wait"
	"github.com/rancher/rancher/tests/integration/pkg/defaults"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"github.com/stretchr/testify/suite"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type HostesdClusterProvisioningTestSuite struct {
	suite.Suite
	client             *rancher.Client
	session            *session.Session
	standardUserClient *rancher.Client
}

func (h *HostesdClusterProvisioningTestSuite) TearDownSuite() {
	h.session.Cleanup()
}

func (h *HostesdClusterProvisioningTestSuite) SetupSuite() {
	testSession := session.NewSession(h.T())
	h.session = testSession

	client, err := rancher.NewClient("", testSession)
	require.NoError(h.T(), err)

	h.client = client

	enabled := true
	var testuser = AppendRandomString("testuser-")
	user := &management.User{
		Username: testuser,
		Password: "<PASSWORD>!",
		Name:     testuser,
		Enabled:  &enabled,
	}

	newUser, err := users.CreateUserWithRole(client, user, "user")
	require.NoError(h.T(), err)

	newUser.Password = <PASSWORD>

	standardUserClient, err := client.AsUser(newUser)
	require.NoError(h.T(), err)

	h.standardUserClient = standardUserClient
}

func (h *HostesdClusterProvisioningTestSuite) TestProvisioningHostedAKSCluster() {
	tests := []struct {
		name   string
		client *rancher.Client
	}{
		{"Admin User", h.client},
		{"Standard User", h.standardUserClient},
	}

	for _, tt := range tests {
		h.Run(tt.name, func() {
			subSession := h.session.NewSession()
			defer subSession.Cleanup()

			client, err := tt.client.WithSession(subSession)
			require.NoError(h.T(), err)

			cloudCredential, err := azure.CreateAzureCloudCredentials(client)
			require.NoError(h.T(), err)

			clusterName := AppendRandomString("ekshostcluster")
			clusterResp, err := aks.CreateAKSHostedCluster(client, clusterName, cloudCredential.ID, false, false, false, false, map[string]string{})
			require.NoError(h.T(), err)

			opts := metav1.ListOptions{
				FieldSelector:  "metadata.name=" + clusterResp.ID,
				TimeoutSeconds: &defaults.WatchTimeoutSeconds,
			}
			watchInterface, err := h.client.GetManagementWatchInterface(management.ClusterType, opts)
			require.NoError(h.T(), err)

			checkFunc := clusters.IsHostedProvisioningClusterReady

			err = wait.WatchWait(watchInterface, checkFunc)
			require.NoError(h.T(), err)
			assert.Equal(h.T(), clusterName, clusterResp.Name)

		})
	}
}

func (h *HostesdClusterProvisioningTestSuite) TestProvisioningHostedEKSCluster() {
	tests := []struct {
		name   string
		client *rancher.Client
	}{
		{"Admin User", h.client},
		{"Standard User", h.standardUserClient},
	}

	for _, tt := range tests {
		h.Run(tt.name, func() {
			subSession := h.session.NewSession()
			defer subSession.Cleanup()

			client, err := tt.client.WithSession(subSession)
{'fraction_non_alphanumeric': 0.13516787815853237, 'fraction_numerical': 0.001557632398753894, 'mean_word_length': 4.872967479674797, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3631459', 'n_tokens_mistral': 2104, 'n_tokens_neox': 2002, 'n_words': 298}