|
1 | | -// Copyright 2025 Keyfactor |
| 1 | +// Copyright 2026 Keyfactor |
2 | 2 | // |
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | // you may not use this file except in compliance with the License. |
|
15 | 15 | using PaloAlto.IntegrationTests.Generators; |
16 | 16 | using PaloAlto.IntegrationTests.Models; |
17 | 17 | using Xunit; |
| 18 | +using Xunit.Abstractions; |
18 | 19 |
|
19 | 20 | namespace PaloAlto.IntegrationTests; |
20 | 21 |
|
21 | 22 | public class ManagementIntegrationTests : BaseIntegrationTest |
22 | 23 | { |
| 24 | + public ManagementIntegrationTests(ITestOutputHelper output) : base(output) |
| 25 | + { |
| 26 | + } |
| 27 | + |
23 | 28 | #region Firewall Tests |
24 | 29 |
|
25 | 30 | [Fact(DisplayName = "TC01: Firewall Enroll No Bindings")] |
@@ -898,4 +903,107 @@ public void TestCase25_PanoramaAdd_Vsys_BoundCert_WithOverride_ShouldSucceed() |
898 | 903 | } |
899 | 904 |
|
900 | 905 | #endregion |
| 906 | + |
| 907 | + #region Alias Length Validation |
| 908 | + |
| 909 | + [Fact(DisplayName = "TC26a: Panorama Enroll when alias name is too long, returns error")] |
| 910 | + public void TestCase26a_PanoramaEnroll_WhenAliasNameIsTooLong_ReturnsFailure() |
| 911 | + { |
| 912 | + var alias = new string('a', 32); |
| 913 | + var certificateContent = PfxGenerator.GetBlobWithChain(alias, MockCertificatePassword); |
| 914 | + |
| 915 | + var props = new TestManagementJobConfigurationProperties() |
| 916 | + { |
| 917 | + StorePath = |
| 918 | + "/config/devices/entry[@name='localhost.localdomain']/template/entry[@name='CertificatesTemplate']/config/shared", |
| 919 | + DeviceGroup = "Group1", |
| 920 | + Alias = alias, |
| 921 | + Overwrite = false, |
| 922 | + |
| 923 | + CertificateContents = certificateContent, |
| 924 | + CertificatePassword = MockCertificatePassword, |
| 925 | + TemplateStack = "" |
| 926 | + }; |
| 927 | + props.AddPanoramaCredentials(); |
| 928 | + |
| 929 | + var result = ProcessManagementAddJob(props); |
| 930 | + |
| 931 | + AssertJobFailure(result, $"Certificate alias '{alias}' is too long, it must not be more than 31 characters. Current length: 32"); |
| 932 | + } |
| 933 | + |
| 934 | + [Fact(DisplayName = "TC26b: Firewall Enroll when alias name is too long, returns error")] |
| 935 | + public void TestCase26b_FirewallEnroll_WhenAliasNameIsTooLong_ReturnsFailure() |
| 936 | + { |
| 937 | + var alias = new string('a', 64); |
| 938 | + var certificateContent = PfxGenerator.GetBlobWithChain(alias, MockCertificatePassword); |
| 939 | + |
| 940 | + var props = new TestManagementJobConfigurationProperties() |
| 941 | + { |
| 942 | + StorePath = |
| 943 | + "/config/shared", |
| 944 | + DeviceGroup = "", |
| 945 | + Alias = alias, |
| 946 | + Overwrite = false, |
| 947 | + |
| 948 | + CertificateContents = certificateContent, |
| 949 | + CertificatePassword = MockCertificatePassword, |
| 950 | + TemplateStack = "" |
| 951 | + }; |
| 952 | + props.AddPanoramaCredentials(); |
| 953 | + |
| 954 | + var result = ProcessManagementAddJob(props); |
| 955 | + |
| 956 | + AssertJobFailure(result, $"Certificate alias '{alias}' is too long, it must not be more than 63 characters. Current length: 64"); |
| 957 | + } |
| 958 | + |
| 959 | + [Fact(DisplayName = "TC26c: Panorama Enroll Enroll Alias Length Valid")] |
| 960 | + public void TestCase26c_PanoramaEnroll_WhenAliasNameValid_NoFailure() |
| 961 | + { |
| 962 | + var alias = new string('a', 31); |
| 963 | + var certificateContent = PfxGenerator.GetBlobWithChain(alias, MockCertificatePassword); |
| 964 | + |
| 965 | + var props = new TestManagementJobConfigurationProperties() |
| 966 | + { |
| 967 | + StorePath = |
| 968 | + "/config/devices/entry[@name='localhost.localdomain']/template/entry[@name='CertificatesTemplate']/config/shared", |
| 969 | + DeviceGroup = "", |
| 970 | + Alias = alias, |
| 971 | + Overwrite = true, |
| 972 | + |
| 973 | + CertificateContents = certificateContent, |
| 974 | + CertificatePassword = MockCertificatePassword, |
| 975 | + TemplateStack = "" |
| 976 | + }; |
| 977 | + props.AddPanoramaCredentials(); |
| 978 | + |
| 979 | + var result = ProcessManagementAddJob(props); |
| 980 | + |
| 981 | + AssertJobSuccess(result, "Add"); |
| 982 | + } |
| 983 | + |
| 984 | + [Fact(DisplayName = "TC26d: Firewall Enroll Alias Length Valid")] |
| 985 | + public void TestCase26d_FirewallEnroll_WhenAliasNameValid_NoFailure() |
| 986 | + { |
| 987 | + var alias = new string('a', 63); |
| 988 | + var certificateContent = PfxGenerator.GetBlobWithChain(alias, MockCertificatePassword); |
| 989 | + |
| 990 | + var props = new TestManagementJobConfigurationProperties() |
| 991 | + { |
| 992 | + StorePath = "/config/shared", |
| 993 | + DeviceGroup = "", |
| 994 | + Alias = alias, |
| 995 | + Overwrite = true, |
| 996 | + |
| 997 | + CertificateContents = certificateContent, |
| 998 | + CertificatePassword = MockCertificatePassword, |
| 999 | + TemplateStack = "" |
| 1000 | + }; |
| 1001 | + props.AddFirewallCredentials(); |
| 1002 | + |
| 1003 | + var result = ProcessManagementAddJob(props); |
| 1004 | + |
| 1005 | + AssertJobSuccess(result, "Add"); |
| 1006 | + } |
| 1007 | + |
| 1008 | + #endregion |
901 | 1009 | } |
0 commit comments