// 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"
	"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 TestAccIosxeServiceTemplate(t *testing.T) {
	var checks []resource.TestCheckFunc
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "name", "MY_TEMPLATE"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "access_groups.0.name", "ag1"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "inactivity_timer", "25"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "inactivity_timer_probe", "false"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "vlan", "27"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "voice_vlan", "false"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "linksec_policy", "must-secure"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "sgt", "57"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "absolute_timer", "45"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "description", "service_template_desc"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "interface_templates.0.name", "template1"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "tunnel_capwap_name", "TUN1"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "vnid", "12345"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "redirect_append_client_mac", "00:01:00:01:00:01"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "redirect_append_switch_mac", "00:01:00:01:00:02"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "redirect_url", "valid_url"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "redirect_url_match_acl", "acl_name"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "redirect_url_match_action", "redirect-on-no-match"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "dns_acl_preauth", "dns_acl_name"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "service_policy_qos_input", "input_qos"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "service_policy_qos_output", "output_qos"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_service_template.test", "tags.0.name", "tag_name"))
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t) },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			{
				Config: testAccIosxeServiceTemplateConfig_minimum(),
			},
			{
				Config: testAccIosxeServiceTemplateConfig_all(),
				Check:  resource.ComposeTestCheckFunc(checks...),
			},
			{
				ResourceName:            "iosxe_service_template.test",
				ImportState:             true,
				ImportStateVerify:       true,
				ImportStateIdFunc:       iosxeServiceTemplateImportStateIdFunc("iosxe_service_template.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 iosxeServiceTemplateImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
	return func(s *terraform.State) (string, error) {
		primary := s.RootModule().Resources[resourceName].Primary
		Name := primary.Attributes["name"]

		return fmt.Sprintf("%s", Name), nil
	}
}

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

// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
// End of section. //template:end testPrerequisites

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

func testAccIosxeServiceTemplateConfig_minimum() string {
	config := `resource "iosxe_service_template" "test" {` + "\n"
	config += `	name = "MY_TEMPLATE"` + "\n"
	config += `}` + "\n"
	return config
}

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

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

func testAccIosxeServiceTemplateConfig_all() string {
	config := `resource "iosxe_service_template" "test" {` + "\n"
	config += `	name = "MY_TEMPLATE"` + "\n"
	config += `	access_groups = [{` + "\n"
	config += `		name = "ag1"` + "\n"
	config += `	}]` + "\n"
	config += `	inactivity_timer = 25` + "\n"
	config += `	inactivity_timer_probe = false` + "\n"
	config += `	vlan = 27` + "\n"
	config += `	voice_vlan = false` + "\n"
	config += `	linksec_policy = "must-secure"` + "\n"
	config += `	sgt = 57` + "\n"
	config += `	absolute_timer = 45` + "\n"
	config += `	description = "service_template_desc"` + "\n"
	config += `	interface_templates = [{` + "\n"
	config += `		name = "template1"` + "\n"
	config += `	}]` + "\n"
	config += `	tunnel_capwap_name = "TUN1"` + "\n"
	config += `	vnid = "12345"` + "\n"
	config += `	redirect_append_client_mac = "00:01:00:01:00:01"` + "\n"
	config += `	redirect_append_switch_mac = "00:01:00:01:00:02"` + "\n"
	config += `	redirect_url = "valid_url"` + "\n"
	config += `	redirect_url_match_acl = "acl_name"` + "\n"
	config += `	redirect_url_match_action = "redirect-on-no-match"` + "\n"
	config += `	dns_acl_preauth = "dns_acl_name"` + "\n"
	config += `	service_policy_qos_input = "input_qos"` + "\n"
	config += `	service_policy_qos_output = "output_qos"` + "\n"
	config += `	tags = [{` + "\n"
	config += `		name = "tag_name"` + "\n"
	config += `	}]` + "\n"
	config += `}` + "\n"
	return config
}

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