// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://mozilla.org/MPL/2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: MPL-2.0

// Code generated by "gen/generator.go"; DO NOT EDIT.

package provider

// Section below is generated&owned by "gen/generator.go". //template:begin imports
import (
	"fmt"
	"os"
	"testing"

	"github.com/hashicorp/terraform-plugin-testing/helper/resource"
	"github.com/hashicorp/terraform-plugin-testing/terraform"
)

// End of section. //template:end imports

// Section below is generated&owned by "gen/generator.go". //template:begin testAcc

func TestAccIosxeCTS(t *testing.T) {
	if os.Getenv("C9000V") == "" {
		t.Skip("skipping test, set environment variable C9000V")
	}
	var checks []resource.TestCheckFunc
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "authorization_list", "Tacacs-GROUP"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sgt", "200"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_enable", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_retry_period", "60"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4.0.ip", "2.2.2.2"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4.0.source_ip", "3.3.3.3"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4.0.connection_mode", "local"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4.0.option", "listener"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4.0.hold_time", "60"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4.0.max_time", "300"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4_vrf.0.ip", "4.4.4.4"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4_vrf.0.vrf", "VRF1"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4_vrf.0.source_ip", "5.5.5.5"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4_vrf.0.connection_mode", "local"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4_vrf.0.option", "listener"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4_vrf.0.hold_time", "60"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_connection_peers_ipv4_vrf.0.max_time", "300"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_speaker_hold_time", "300"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_listener_hold_min_time", "60"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "sxp_listener_hold_max_time", "300"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_cts.test", "role_based_enforcement_logging_interval", "300"))
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t) },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			{
				Config: testAccIosxeCTSPrerequisitesConfig + testAccIosxeCTSConfig_minimum(),
			},
			{
				Config: testAccIosxeCTSPrerequisitesConfig + testAccIosxeCTSConfig_all(),
				Check:  resource.ComposeTestCheckFunc(checks...),
			},
			{
				ResourceName:            "iosxe_cts.test",
				ImportState:             true,
				ImportStateVerify:       true,
				ImportStateIdFunc:       iosxeCTSImportStateIdFunc("iosxe_cts.test"),
				ImportStateVerifyIgnore: []string{},
				Check:                   resource.ComposeTestCheckFunc(checks...),
			},
		},
	})
}

// End of section. //template:end testAcc

// Section below is generated&owned by "gen/generator.go". //template:begin importStateIdFunc

func iosxeCTSImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
	return func(s *terraform.State) (string, error) {

		return fmt.Sprintf(""), nil
	}
}

// End of section. //template:end importStateIdFunc

// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeCTSPrerequisitesConfig = `
resource "iosxe_restconf" "PreReq0" {
	path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
	delete = false
	attributes = {
		"name" = "VRF1"
		"rd" = "1:1"
		"address-family/ipv4" = ""
	}
}

`

// End of section. //template:end testPrerequisites

// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigMinimal

func testAccIosxeCTSConfig_minimum() string {
	config := `resource "iosxe_cts" "test" {` + "\n"
	config += `	depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
	config += `}` + "\n"
	return config
}

// End of section. //template:end testAccConfigMinimal

// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll

func testAccIosxeCTSConfig_all() string {
	config := `resource "iosxe_cts" "test" {` + "\n"
	config += `	authorization_list = "Tacacs-GROUP"` + "\n"
	config += `	sgt = 200` + "\n"
	config += `	sxp_enable = true` + "\n"
	config += `	sxp_default_password_type = "0"` + "\n"
	config += `	sxp_default_password = "MySecretPassword"` + "\n"
	config += `	sxp_retry_period = 60` + "\n"
	config += `	sxp_connection_peers_ipv4 = [{` + "\n"
	config += `		ip = "2.2.2.2"` + "\n"
	config += `		source_ip = "3.3.3.3"` + "\n"
	config += `		password = "default"` + "\n"
	config += `		connection_mode = "local"` + "\n"
	config += `		option = "listener"` + "\n"
	config += `		hold_time = 60` + "\n"
	config += `		max_time = 300` + "\n"
	config += `	}]` + "\n"
	config += `	sxp_connection_peers_ipv4_vrf = [{` + "\n"
	config += `		ip = "4.4.4.4"` + "\n"
	config += `		vrf = "VRF1"` + "\n"
	config += `		source_ip = "5.5.5.5"` + "\n"
	config += `		password = "default"` + "\n"
	config += `		connection_mode = "local"` + "\n"
	config += `		option = "listener"` + "\n"
	config += `		hold_time = 60` + "\n"
	config += `		max_time = 300` + "\n"
	config += `	}]` + "\n"
	config += `	sxp_speaker_hold_time = 300` + "\n"
	config += `	sxp_listener_hold_min_time = 60` + "\n"
	config += `	sxp_listener_hold_max_time = 300` + "\n"
	config += `	role_based_enforcement_logging_interval = 300` + "\n"
	config += `	depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
	config += `}` + "\n"
	return config
}

// End of section. //template:end testAccConfigAll
