source: dispositivos_moviles/jdigidoc-3.7/jdigidoc/tests/jdigidoc_spec.rb @ 95d372e

Last change on this file since 95d372e was 62396ee, checked in by Antonio Araujo Brett <aaraujo@…>, 11 years ago

Códigos fuentes de la biblioteca jdigidoc usada en Android.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1require 'spec'
2require 'spec/runner/formatter/html_formatter'
3require "helper/helper_methods"
4
5module Spec
6  module Runner
7    module Formatter
8      class HtmlFormatter < BaseTextFormatter
9        def extra_failure_content(failure)
10          "    <pre class=\"ruby\"><code>#{$output}</code></pre>"
11        end
12      end
13    end
14  end
15end
16
17describe 'jdigidoc (j) and cdigidoc (c) libraries' do
18
19  before :all do
20    prepare_environment()
21    `pkcs15-tool -r 1 > cert.pem`
22  end
23
24  before :each do
25    @file = "sample.txt"
26    system "cp -f sample_data/#{@file}.original sample_data/#{@file}"
27    $output = "CLASSPATH=#{ENV['CLASSPATH']}\n\n"
28  end
29
30  after :each do
31    system "rm sample_data/#{@file}"
32  end
33
34  after :all do
35    system "rm -f *.txt"
36    system "rm -f signer.pem"
37    system "rm -f sample_data/*.zip"
38  end
39
40  #["DIGIDOC-XML 1.3", "DIGIDOC-XML 1.2", "DIGIDOC-XML 1.1", "BDOC 1.0"].each do |format|
41  ["DIGIDOC-XML 1.3", "DIGIDOC-XML 1.2", "DIGIDOC-XML 1.1"].each do |format|
42    it "should create (j), add (j), sign (j), verify (c) and extract (c) with format #{format}" do
43      sign_and_verify(:jdigidoc, :cdigidoc, format)
44    end
45                                                                               
46    it "should create (c), add (c), sign (c), verify (j) and extract (j) with format #{format}" do
47      sign_and_verify(:cdigidoc, :jdigidoc, format)
48    end
49
50    it "should create (c), add (c), add (j), sign (j), verify (c) and extract (j) with format #{format}" do
51      add_sign_and_verify(:jdigidoc, :cdigidoc, format)
52    end
53
54    it "should create (j), add (j), add (c), sign (c), verify (j) and extract (c) with format #{format}" do
55      add_sign_and_verify(:cdigidoc, :jdigidoc, format)
56    end
57  end
58
59  it "should encrypt (j) and decrypt (c)" do
60    encrypt(:jdigidoc)
61    decrypt_and_verify(:cdigidoc)
62  end
63
64  it "should encrypt (c) and decrypt (j)" do
65    encrypt(:cdigidoc)
66    decrypt_and_verify(:jdigidoc)
67  end
68
69  it "should sign (j) large (100M) file durig acceptable time and verify (c) signature" do
70    @file = "large_file"
71
72    create_large_file(100)
73
74    zipping_time = get_zipping_time()
75   
76    start_time = Time.now
77    sign_for_format(:jdigidoc, "DIGIDOC-XML 1.3")
78    time_spent = (Time.now - start_time)
79
80    # there is requirement that signing can take double of zipping time i.e. must not exeed 15 sec for 100MB file
81    max_acceptable_signing_time = 10 * zipping_time
82    if time_spent > max_acceptable_signing_time
83      raise "signin took to long (#{time_spent} sec, max acceptable signing time on this system is #{max_acceptable_signing_time} sec)"
84    end
85
86    # todo: add verify
87  end
88
89end
Note: See TracBrowser for help on using the repository browser.