Skip to content

Commit 04a52a5

Browse files
committed
Add misc test suites.
1 parent cc0023a commit 04a52a5

16 files changed

+2784
-2
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
%%% % DO NOT EDIT: this file was generated by 'just codegen'
2+
%%% % @generated SignedSource<<195f1ee5f3090e786068d78d5d613ac4>>
3+
%%% % @format
4+
%%%-----------------------------------------------------------------------------
5+
%%% Copyright (c) Meta Platforms, Inc. and affiliates.
6+
%%% Copyright (c) WhatsApp LLC
7+
%%%
8+
%%% This source code is licensed under the MIT license found in the
9+
%%% LICENSE.md file in the root directory of this source tree.
10+
%%%-----------------------------------------------------------------------------
11+
-module(markdown_misc_bom_SUITE).
12+
-moduledoc """
13+
14+
""".
15+
-moduledoc #{author => ["Andrew Bennett <[email protected]>"]}.
16+
-moduledoc #{created => "", modified => ""}.
17+
-moduledoc #{copyright => "Meta Platforms, Inc. and affiliates."}.
18+
-compile(warn_missing_spec_all).
19+
-oncall("whatsapp_clr").
20+
21+
-include_lib("markdown/include/markdown_mdast.hrl").
22+
-include_lib("markdown/include/markdown_util.hrl").
23+
-include_lib("stdlib/include/assert.hrl").
24+
25+
-behaviour(ct_suite).
26+
27+
%% ct_suite callbacks
28+
-export([
29+
all/0,
30+
groups/0,
31+
init_per_suite/1,
32+
end_per_suite/1,
33+
init_per_group/2,
34+
end_per_group/2
35+
]).
36+
37+
%% Test Cases
38+
-export([
39+
test_misc_bom_case_1/1,
40+
test_misc_bom_case_2/1
41+
]).
42+
43+
%%%=============================================================================
44+
%%% ct_suite callbacks
45+
%%%=============================================================================
46+
47+
-spec all() -> markdown_test:all().
48+
all() ->
49+
[
50+
{group, static}
51+
].
52+
53+
-spec groups() -> markdown_test:groups().
54+
groups() ->
55+
[
56+
{static, [parallel], [
57+
test_misc_bom_case_1,
58+
test_misc_bom_case_2
59+
]}
60+
].
61+
62+
-spec init_per_suite(Config :: ct_suite:ct_config()) -> markdown_test:init_per_suite().
63+
init_per_suite(Config) ->
64+
Config.
65+
66+
-spec end_per_suite(Config :: ct_suite:ct_config()) -> markdown_test:end_per_suite().
67+
end_per_suite(_Config) ->
68+
ok.
69+
70+
-spec init_per_group(GroupName :: ct_suite:ct_groupname(), Config :: ct_suite:ct_config()) ->
71+
markdown_test:init_per_group().
72+
init_per_group(_Group, Config) ->
73+
Config.
74+
75+
-spec end_per_group(GroupName :: ct_suite:ct_groupname(), Config :: ct_suite:ct_config()) ->
76+
markdown_test:end_per_group().
77+
end_per_group(_Group, _Config) ->
78+
ok.
79+
80+
%%%=============================================================================
81+
%%% Test Cases
82+
%%%=============================================================================
83+
84+
-spec test_misc_bom_case_1(Config) -> markdown_test:testcase() when
85+
Config :: ct_suite:ct_config().
86+
test_misc_bom_case_1(_Config) ->
87+
?assertMatch(
88+
{ok, <<""/utf8>>},
89+
markdown:to_html(<<""/utf8>>),
90+
"should ignore just a bom"
91+
),
92+
ok.
93+
94+
-spec test_misc_bom_case_2(Config) -> markdown_test:testcase() when
95+
Config :: ct_suite:ct_config().
96+
test_misc_bom_case_2(_Config) ->
97+
?assertMatch(
98+
{ok, <<"<h1>heading</h1>"/utf8>>},
99+
markdown:to_html(<<"# heading"/utf8>>),
100+
"should ignore a bom"
101+
),
102+
ok.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
%%% % DO NOT EDIT: this file was generated by 'just codegen'
2+
%%% % @generated SignedSource<<dfbe93f4dfbf1c353aff0952ab1d06ad>>
3+
%%% % @format
4+
%%%-----------------------------------------------------------------------------
5+
%%% Copyright (c) Meta Platforms, Inc. and affiliates.
6+
%%% Copyright (c) WhatsApp LLC
7+
%%%
8+
%%% This source code is licensed under the MIT license found in the
9+
%%% LICENSE.md file in the root directory of this source tree.
10+
%%%-----------------------------------------------------------------------------
11+
-module(markdown_misc_dangerous_html_SUITE).
12+
-moduledoc """
13+
14+
""".
15+
-moduledoc #{author => ["Andrew Bennett <[email protected]>"]}.
16+
-moduledoc #{created => "", modified => ""}.
17+
-moduledoc #{copyright => "Meta Platforms, Inc. and affiliates."}.
18+
-compile(warn_missing_spec_all).
19+
-oncall("whatsapp_clr").
20+
21+
-include_lib("markdown/include/markdown_mdast.hrl").
22+
-include_lib("markdown/include/markdown_util.hrl").
23+
-include_lib("stdlib/include/assert.hrl").
24+
25+
-behaviour(ct_suite).
26+
27+
%% ct_suite callbacks
28+
-export([
29+
all/0,
30+
groups/0,
31+
init_per_suite/1,
32+
end_per_suite/1,
33+
init_per_group/2,
34+
end_per_group/2
35+
]).
36+
37+
%% Test Cases
38+
-export([
39+
test_misc_dangerous_html_case_1/1,
40+
test_misc_dangerous_html_case_2/1,
41+
test_misc_dangerous_html_case_3/1
42+
]).
43+
44+
%% Macros
45+
-define(danger, markdown_options:new(#{compile => #{allow_dangerous_html => true, allow_dangerous_protocol => true}})).
46+
47+
%%%=============================================================================
48+
%%% ct_suite callbacks
49+
%%%=============================================================================
50+
51+
-spec all() -> markdown_test:all().
52+
all() ->
53+
[
54+
{group, static}
55+
].
56+
57+
-spec groups() -> markdown_test:groups().
58+
groups() ->
59+
[
60+
{static, [parallel], [
61+
test_misc_dangerous_html_case_1,
62+
test_misc_dangerous_html_case_2,
63+
test_misc_dangerous_html_case_3
64+
]}
65+
].
66+
67+
-spec init_per_suite(Config :: ct_suite:ct_config()) -> markdown_test:init_per_suite().
68+
init_per_suite(Config) ->
69+
Config.
70+
71+
-spec end_per_suite(Config :: ct_suite:ct_config()) -> markdown_test:end_per_suite().
72+
end_per_suite(_Config) ->
73+
ok.
74+
75+
-spec init_per_group(GroupName :: ct_suite:ct_groupname(), Config :: ct_suite:ct_config()) ->
76+
markdown_test:init_per_group().
77+
init_per_group(_Group, Config) ->
78+
Config.
79+
80+
-spec end_per_group(GroupName :: ct_suite:ct_groupname(), Config :: ct_suite:ct_config()) ->
81+
markdown_test:end_per_group().
82+
end_per_group(_Group, _Config) ->
83+
ok.
84+
85+
%%%=============================================================================
86+
%%% Test Cases
87+
%%%=============================================================================
88+
89+
-spec test_misc_dangerous_html_case_1(Config) -> markdown_test:testcase() when
90+
Config :: ct_suite:ct_config().
91+
test_misc_dangerous_html_case_1(_Config) ->
92+
?assertMatch(
93+
{ok, <<"&lt;x&gt;"/utf8>>},
94+
markdown:to_html(<<"<x>"/utf8>>),
95+
"should be safe by default for flow"
96+
),
97+
ok.
98+
99+
-spec test_misc_dangerous_html_case_2(Config) -> markdown_test:testcase() when
100+
Config :: ct_suite:ct_config().
101+
test_misc_dangerous_html_case_2(_Config) ->
102+
?assertMatch(
103+
{ok, <<"<p>a&lt;b&gt;</p>"/utf8>>},
104+
markdown:to_html(<<"a<b>"/utf8>>),
105+
"should be safe by default for text"
106+
),
107+
ok.
108+
109+
-spec test_misc_dangerous_html_case_3(Config) -> markdown_test:testcase() when
110+
Config :: ct_suite:ct_config().
111+
test_misc_dangerous_html_case_3(_Config) ->
112+
?assertMatch(
113+
{ok, <<"<x>"/utf8>>},
114+
markdown:to_html_with_options(<<"<x>"/utf8>>, ?danger),
115+
"should be unsafe w/ `allowDangerousHtml`"
116+
),
117+
ok.

0 commit comments

Comments
 (0)