diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 14:23:34 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 14:23:34 +0000 |
commit | 3e5f4a8802d60908fe3bcf56a72afd15e1a4777a (patch) | |
tree | c0f216d842e657a01c85ec031bfbae0a927cbc62 /spec | |
parent | b9bf11ef5f63203c6974c4432553270f7b3d29a1 (diff) | |
download | gitlab-ce-3e5f4a8802d60908fe3bcf56a72afd15e1a4777a.tar.gz |
Add latest changes from gitlab-org/security/gitlab@12-7-stable-ee
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/asciidoc/include_processor_spec.rb | 44 | ||||
-rw-r--r-- | spec/lib/gitlab/asciidoc_spec.rb | 18 |
2 files changed, 0 insertions, 62 deletions
diff --git a/spec/lib/gitlab/asciidoc/include_processor_spec.rb b/spec/lib/gitlab/asciidoc/include_processor_spec.rb deleted file mode 100644 index 5fec4d9e208..00000000000 --- a/spec/lib/gitlab/asciidoc/include_processor_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -require 'nokogiri' - -describe Gitlab::Asciidoc::IncludeProcessor do - let_it_be(:project) { create(:project, :repository) } - - let(:processor_context) do - { - project: project, - max_includes: max_includes, - ref: ref - } - end - let(:ref) { project.repository.root_ref } - let(:max_includes) { 10 } - - let(:reader) { Asciidoctor::PreprocessorReader.new(document, lines, 'file.adoc') } - let(:document) { Asciidoctor::Document.new(lines) } - - subject(:processor) { described_class.new(processor_context) } - - let(:a_blob) { double(:Blob, readable_text?: true, data: a_data) } - let(:a_data) { StringIO.new('include::b.adoc[]') } - - let(:lines) { [':max-include-depth: 1000'] + Array.new(10, 'include::a.adoc[]') } - - before do - allow(project.repository).to receive(:blob_at).with(ref, 'a.adoc').and_return(a_blob) - end - - describe '#include_allowed?' do - it 'allows the first include' do - expect(processor.send(:include_allowed?, 'foo.adoc', reader)).to be_truthy - end - - it 'disallows the Nth + 1 include' do - max_includes.times { processor.send(:read_blob, ref, 'a.adoc') } - - expect(processor.send(:include_allowed?, 'foo.adoc', reader)).to be_falsey - end - end -end diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index c7156a500d0..c8d159d1e84 100644 --- a/spec/lib/gitlab/asciidoc_spec.rb +++ b/spec/lib/gitlab/asciidoc_spec.rb @@ -425,24 +425,6 @@ module Gitlab create_file(current_file, "= AsciiDoc\n") end - def many_includes(target) - Array.new(10, "include::#{target}[]").join("\n") - end - - context 'cyclic imports' do - before do - create_file('doc/api/a.adoc', many_includes('b.adoc')) - create_file('doc/api/b.adoc', many_includes('a.adoc')) - end - - let(:include_path) { 'a.adoc' } - let(:requested_path) { 'doc/api/README.md' } - - it 'completes successfully' do - is_expected.to include('<p>Include this:</p>') - end - end - context 'with path to non-existing file' do let(:include_path) { 'not-exists.adoc' } |