annotate spec/util_tlsref_spec.lua @ 14218:926f25af2ffe 13.0

util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations Previously we embedded this data directly into core.certmanager. This splits it out, for various benefits: - Removes data from the business logic (the config parsing is complex enough as it is) - Allows easier testing and tracking of the data (this commit adds various consistency checks, so that we can have more confidence in future updates to the data not breaking stuff) This library also supports multiple versions of the recommendations. Previously we picked a single version, and put that into certmanager. But this meant we had to make choices for our users, and one of the choices is between advancing security standards and ensuring we don't break connectivity for people doing minor upgrades (deterring people from performing minor upgrades would have a security impact too). This library supports the concept of a "default" and a "latest" version, so we are now free to add new versions into stable releases, and admins can pick between compatibility and security.
author Matthew Wild <mwild1@gmail.com>
date Fri, 12 Jun 2026 13:01:56 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14218
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local tlsref = require "prosody.util.tlsref";
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 describe("util.tlsref", function()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local version_compare = require "prosody.util.human.io".simple_version_compare;
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 describe("default version", function()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 it("is not greater than latest version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 local default_version = tlsref.get_default_version();
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 local latest_version = tlsref.get_latest_version();
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 assert.equal(false, version_compare(latest_version, default_version));
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 it("is a known version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 assert.is_table(tlsref.get_profile(tlsref.get_default_version()));
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 describe("latest version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 it("is a known version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 assert.is_table(tlsref.get_profile("latest"));
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 it("is the first entry of get_valid_versions()", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 local versions = tlsref.get_valid_versions();
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 assert.equal(tlsref.get_latest_version(), versions[1]);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 describe("get_valid_versions()", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 it("returns versions in descending order", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 local versions = tlsref.get_valid_versions();
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 assert.is_true(#versions >= 1);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 for i = 1, #versions-1 do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 -- versions[i] must sort before versions[i+1]
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 assert.equal(false, version_compare(versions[i], versions[i+1]));
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 it("contains the default version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 local found = false;
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 for _, v in ipairs(tlsref.get_valid_versions()) do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 if v == tlsref.get_default_version() then found = true; end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 assert.is_true(found);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 describe("get_valid_profile_names()", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 it("returns an error for unknown versions", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 local names, err = tlsref.get_valid_profile_names("0.0");
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 assert.is_nil(names);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 assert.equal("unknown-version", err);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 it("uses the default version when none is given", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 assert.same(
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 tlsref.get_valid_profile_names(tlsref.get_default_version()),
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 tlsref.get_valid_profile_names()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 );
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 it("accepts 'latest' as a version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 assert.same(
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 tlsref.get_valid_profile_names(tlsref.get_latest_version()),
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 tlsref.get_valid_profile_names("latest")
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 );
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 it("lists the most-preferred profile first", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 for _, version in ipairs(tlsref.get_valid_versions()) do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 local names = tlsref.get_valid_profile_names(version);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 assert.equal("modern", names[1],
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 ("most-preferred profile should be first for version %s"):format(version));
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 describe("get_profile()", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79 it("returns the default profile of the default version when called with no arguments", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 assert.equal(
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 tlsref.get_profile(tlsref.get_default_version(), tlsref.get_default_profile_name()),
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 tlsref.get_profile()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 );
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 it("resolves 'latest' to the latest version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 assert.equal(
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 tlsref.get_profile(tlsref.get_latest_version()),
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 tlsref.get_profile("latest")
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 );
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 it("returns an error for unknown versions", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 local profile, err = tlsref.get_profile("0.0");
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 assert.is_nil(profile);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 assert.equal("unknown-version", err);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 it("returns an error for unknown profile names", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100 local profile, err = tlsref.get_profile(nil, "no-such-profile");
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 assert.is_nil(profile);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 assert.equal("unknown-profile", err);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 it("returns an error for profiles absent from a given version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 -- 'old' was dropped from the 6.0 guidelines
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 local profile, err = tlsref.get_profile("6.0", "old");
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 assert.is_nil(profile);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 assert.equal("unknown-profile", err);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 it("resolves every advertised version/profile combination", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
113 for _, version in ipairs(tlsref.get_valid_versions()) do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 for _, name in ipairs(tlsref.get_valid_profile_names(version)) do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 local profile, err = tlsref.get_profile(version, name);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 assert.is_table(profile,
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 ("get_profile(%q, %q) failed: %s"):format(version, name, err));
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 describe("get_default_profile_name()", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 it("returns an error for unknown versions", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 local name, err = tlsref.get_default_profile_name("0.0");
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 assert.is_nil(name);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 assert.equal("unknown-version", err);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 it("accepts 'latest' as a version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 assert.is_string(tlsref.get_default_profile_name("latest"));
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 it("returns a profile name valid for every version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 for _, version in ipairs(tlsref.get_valid_versions()) do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 local name = tlsref.get_default_profile_name(version);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 assert.is_string(name);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 assert.is_table(tlsref.get_profile(version, name),
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 ("default profile %q missing from version %s"):format(name, version));
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
141 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
142 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
143
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 describe("profile contents", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145 it("every profile specifies a TLS protocol version", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
146 for _, version in ipairs(tlsref.get_valid_versions()) do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
147 for _, name in ipairs(tlsref.get_valid_profile_names(version)) do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
148 local profile = tlsref.get_profile(version, name);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
149 assert.is_string(profile.protocol);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150 assert.truthy(profile.protocol:match("^tlsv1"),
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 ("unexpected protocol %q in %s/%s"):format(profile.protocol, version, name));
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
152 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
153 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
154 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
155
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
156 it("every profile specifies TLS 1.3 ciphersuites and curves", function ()
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
157 for _, version in ipairs(tlsref.get_valid_versions()) do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
158 for _, name in ipairs(tlsref.get_valid_profile_names(version)) do
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 local profile = tlsref.get_profile(version, name);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 assert.is_table(profile.ciphersuites);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 assert.is_true(#profile.ciphersuites > 0);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162 assert.is_table(profile.curveslist);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 assert.is_true(#profile.curveslist > 0);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 end
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167 end);
926f25af2ffe util.tlsref: New util library to encapsulate the Mozilla/TLSRef recommendations
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168 end);