|
1153 | 1153 | (select-keys % [:kind :msg]))] |
1154 | 1154 | ["invalid characters in name" "super/bad" "bad-subject-name-1.pem" |
1155 | 1155 | #(= {:kind :invalid-subject-name |
1156 | | - :msg "Subject contains unprintable or non-ASCII characters"} |
| 1156 | + :msg "Subject hostname format is invalid"} |
1157 | 1157 | (select-keys % [:kind :msg]))] |
1158 | 1158 | ["wildcard in name" "foo*bar" "bad-subject-name-wildcard.pem" |
1159 | 1159 | #(= {:kind :invalid-subject-name |
|
1189 | 1189 | (select-keys % [:kind :msg]))] |
1190 | 1190 | ["subject contains invalid characters" "super/bad" "bad-subject-name-1.pem" |
1191 | 1191 | #(= {:kind :invalid-subject-name |
1192 | | - :msg "Subject contains unprintable or non-ASCII characters"} |
| 1192 | + :msg "Subject hostname format is invalid"} |
1193 | 1193 | (select-keys % [:kind :msg]))] |
1194 | 1194 | ["subject contains wildcard character" "foo*bar" "bad-subject-name-wildcard.pem" |
1195 | 1195 | #(= {:kind :invalid-subject-name |
|
1609 | 1609 | (deftest validate-subject!-test |
1610 | 1610 | (testing "an exception is thrown when the hostnames don't match" |
1611 | 1611 | (is (thrown+? |
1612 | | - [:kind :hostname-mismatch |
1613 | | - :msg "Instance name \"test-agent\" does not match requested key \"not-test-agent\""] |
1614 | | - (validate-subject! |
1615 | | - "not-test-agent" "test-agent")))) |
| 1612 | + [:kind :hostname-mismatch |
| 1613 | + :msg "Instance name \"test-agent\" does not match requested key \"not-test-agent\""] |
| 1614 | + (validate-subject! |
| 1615 | + "not-test-agent" "test-agent")))) |
1616 | 1616 |
|
1617 | 1617 | (testing "an exception is thrown if the subject name contains a capital letter" |
1618 | 1618 | (is (thrown+? |
1619 | | - [:kind :invalid-subject-name |
1620 | | - :msg "Certificate names must be lower case."] |
1621 | | - (validate-subject! "Host-With-Capital-Letters" |
1622 | | - "Host-With-Capital-Letters"))))) |
| 1619 | + [:kind :invalid-subject-name |
| 1620 | + :msg "Certificate names must be lower case."] |
| 1621 | + (validate-subject! "Host-With-Capital-Letters" |
| 1622 | + "Host-With-Capital-Letters")))) |
| 1623 | + |
| 1624 | + (testing "an exception is thrown when the hostnames ends in hyphen" |
| 1625 | + (is (thrown+? |
| 1626 | + [:kind :invalid-subject-name |
| 1627 | + :msg "Subject hostname format is invalid"] |
| 1628 | + (validate-subject! |
| 1629 | + "rootca-.example.org" "rootca-.example.org")))) |
| 1630 | + |
| 1631 | + (testing "an exception is thrown when the hostnames starts with hyphen" |
| 1632 | + (is (thrown+? |
| 1633 | + [:kind :invalid-subject-name |
| 1634 | + :msg "Subject hostname format is invalid"] |
| 1635 | + (validate-subject! |
| 1636 | + "-rootca.example.org" "-rootca.example.org")))) |
| 1637 | + |
| 1638 | + (testing "an exception is thrown when the hostnames contains a space" |
| 1639 | + (is (thrown+? |
| 1640 | + [:kind :invalid-subject-name |
| 1641 | + :msg "Subject hostname format is invalid"] |
| 1642 | + (validate-subject! |
| 1643 | + "root ca.example.org" "root ca.example.org")))) |
| 1644 | + |
| 1645 | + (testing "an exception is thrown when the hostnames contain an ampersand" |
| 1646 | + (is (thrown+? |
| 1647 | + [:kind :invalid-subject-name |
| 1648 | + :msg "Subject hostname format is invalid"] |
| 1649 | + (validate-subject! |
| 1650 | + "root&ca.example.org" "root&ca.example.org")))) |
| 1651 | + |
| 1652 | + (testing "an exception is thrown when the hostname is empty" |
| 1653 | + (is (thrown+? |
| 1654 | + [:kind :invalid-subject-name |
| 1655 | + :msg "Subject hostname format is invalid"] |
| 1656 | + (validate-subject! |
| 1657 | + "" "")))) |
| 1658 | + |
| 1659 | + (testing "an exception is thrown when the hostnames contain multiple dots in a row" |
| 1660 | + (is (thrown+? |
| 1661 | + [:kind :invalid-subject-name |
| 1662 | + :msg "Subject hostname format is invalid"] |
| 1663 | + (validate-subject! |
| 1664 | + "rootca..example.org" "rootca..example.org")))) |
| 1665 | + |
| 1666 | + (testing "an exception is thrown when the hostnames end in dot" |
| 1667 | + (is (thrown+? |
| 1668 | + [:kind :invalid-subject-name |
| 1669 | + :msg "Subject hostname format is invalid"] |
| 1670 | + (validate-subject! |
| 1671 | + "rootca." "rootca.")))) |
| 1672 | + |
| 1673 | + (testing "Single word hostnames are allowed" |
| 1674 | + (is (nil? |
| 1675 | + (validate-subject! |
| 1676 | + "rootca" "rootca")))) |
| 1677 | + |
| 1678 | + (testing "Domain names are allowed" |
| 1679 | + (is (nil? |
| 1680 | + (validate-subject! |
| 1681 | + "puppet.com" "puppet.com")))) |
| 1682 | + |
| 1683 | + (testing "Subdomains are allowed" |
| 1684 | + (is (nil? |
| 1685 | + (validate-subject! |
| 1686 | + "ca.puppet.com" "ca.puppet.com")))) |
| 1687 | + |
| 1688 | + (testing "Hostnames containing underscores are allowed" |
| 1689 | + (is (nil? |
| 1690 | + (validate-subject! |
| 1691 | + "root_ca" "root_ca")))) |
| 1692 | + |
| 1693 | + (testing "Hostnames containing dashes are allowed" |
| 1694 | + (is (nil? |
| 1695 | + (validate-subject! |
| 1696 | + "root-ca" "root-ca")))) |
| 1697 | + |
| 1698 | + (testing "Hostnames containing numbers are allowed" |
| 1699 | + (is (nil? |
| 1700 | + (validate-subject! |
| 1701 | + "root123" "root123")))) |
| 1702 | + |
| 1703 | + (testing "Domains containing numbers are allowed" |
| 1704 | + (is (nil? |
| 1705 | + (validate-subject! |
| 1706 | + "root123.com" "root123.com"))))) |
1623 | 1707 |
|
1624 | 1708 | (deftest validate-subject-alt-names!-test |
1625 | 1709 | (testing "Both DNS and IP alt names are allowed" |
|
0 commit comments