Skip to content

Fix invalid XML message with nested CDATA section causes in ut_realtime_reporter #1075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ PROMPT Creating $UT3_USER - minimal privileges user for API testing
create user $UT3_USER identified by "$UT3_USER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE;
grant create session, create procedure, create type, create table to $UT3_USER;

PROMPT Grants for starting a debugging session from $UT3_USER
grant debug connect session to $UT3_USER;
grant debug any procedure to $UT3_USER;
begin
\$if dbms_db_version.version <= 11 \$then
null; -- no addition action necessary
\$else
-- necessary on 12c or higher
dbms_network_acl_admin.append_host_ace (
host =>'*',
ace => sys.xs\$ace_type(
privilege_list => sys.xs\$name_list('JDWP') ,
principal_name => '$UT3_USER',
principal_type => sys.xs_acl.ptype_db
)
);
\$end
end;
/

--------------------------------------------------------------------------------
PROMPT Creating $UT3_TESTER_HELPER - provides functions to allow min grant test user setup tests.
Expand Down
2 changes: 1 addition & 1 deletion source/reporters/ut_realtime_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ create or replace type body ut_realtime_reporter is
) is
begin
if a_content is not null then
self.print_xml_fragment('<' || a_name || '><![CDATA[' || a_content || ']]></' || a_name || '>');
self.print_xml_fragment('<' || a_name || '><![CDATA[' || ut_utils.to_cdata(a_content) || ']]></' || a_name || '>');
end if;
end print_cdata_node;

Expand Down
46 changes: 46 additions & 0 deletions test/ut3_user/reporters/test_realtime_reporter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ create or replace package body test_realtime_reporter as
end;
end;]';

execute immediate q'[create or replace package check_realtime_reporting5 is
--%suite
--%suitepath(realtime_reporting_bufix)

--%test(test XML with nested CDATA)
procedure test_nested_cdata;
end;]';

execute immediate q'[create or replace package body check_realtime_reporting5 is
procedure test_nested_cdata is
begin
dbms_output.put_line('nested cdata block: <![CDATA[...]]>, to be handled.');
ut.expect(1).to_equal(1);
end;
end;]';

<<run_report_and_cache_result>>
declare
l_reporter ut3_develop.ut_realtime_reporter := ut3_develop.ut_realtime_reporter();
Expand Down Expand Up @@ -448,6 +464,35 @@ create or replace package body test_realtime_reporter as
l_actual := l_reporter.get_description();
ut.expect(l_actual).to_be_like(l_expected);
end get_description;

procedure nested_cdata_output is
l_text varchar2(4000);
l_xml xmltype;
--
function produce_and_consume return varchar2 is
pragma autonomous_transaction;
l_reporter ut3_develop.ut_realtime_reporter := ut3_develop.ut_realtime_reporter();
l_text varchar2(4000);
begin
-- produce
ut3_develop.ut_runner.run(
a_paths => ut3_develop.ut_varchar2_list(':realtime_reporting_bufix'),
a_reporters => ut3_develop.ut_reporters(l_reporter)
);
-- consume
select text
into l_text
from table(l_reporter.get_lines())
where item_type = 'post-test';
return l_text;
end produce_and_consume;
begin
l_text := produce_and_consume();
ut.expect(l_text).to_be_not_null();
-- this fails, if l_text is not a valid XML
l_xml := xmltype(l_text);
ut.expect(l_xml is not null).to_be_true();
end;

procedure remove_test_suites is
pragma autonomous_transaction;
Expand All @@ -456,6 +501,7 @@ create or replace package body test_realtime_reporter as
execute immediate 'drop package check_realtime_reporting2';
execute immediate 'drop package check_realtime_reporting3';
execute immediate 'drop package check_realtime_reporting4';
execute immediate 'drop package check_realtime_reporting5';
end remove_test_suites;

end test_realtime_reporter;
Expand Down
3 changes: 3 additions & 0 deletions test/ut3_user/reporters/test_realtime_reporter.pks
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ create or replace package test_realtime_reporter as
--%test(Provide a description of the reporter explaining the use for SQL Developer)
procedure get_description;

--%test(Escape nested CDATA sections in test output)
procedure nested_cdata_output;

--%afterall
procedure remove_test_suites;

Expand Down