Sha256: 7a0bbf951fc2fb532155d204ebd471b3735ad24c672f7fec5af66a3d2e92873c

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'
require 'r509/crl/sqlite_reader_writer'

describe R509::CRL::SQLiteReaderWriter do

  let(:empty_db) { SQLite3::Database.new ':memory:' }
  let(:db) do
    db = SQLite3::Database.new ':memory:'
    db.execute_batch TestFixtures::CRL_LIST_SQLITE
    db
  end
  let(:rw) { R509::CRL::SQLiteReaderWriter.new db }

  it 'creates the schema automatically if its missing' do
    R509::CRL::SQLiteReaderWriter.new empty_db
    expect(db.execute('SELECT * FROM sqlite_master')).not_to be_empty
  end

  it 'reads a crl list' do
    expect { |b| rw.read_list(&b) }.to yield_successive_args([12345, 0, 1323983885], [12346, nil, 1323983885])
  end

  it 'writes a crl list entry' do
    rw.write_list_entry(1, 1, nil)
    expect(db.execute("SELECT * FROM revoked_serials WHERE serial='1' AND revoked_at=1 AND reason is null")).not_to be_empty
  end

  it 'removes a crl list entry' do
    rw.remove_list_entry(12345)
    expect(db.execute("SELECT * FROM revoked_serials WHERE serial='12345'")).to be_empty
  end

  it 'reads a number' do
    db.execute("UPDATE crl_number set number=5")
    expect(rw.read_number).to eq(5)
  end

  it 'writes a crl number' do
    rw.write_number 6
    expect(db.get_first_value("SELECT number from crl_number")).to eq(6)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
r509-1.0.1 spec/crl/sqlite_reader_writer_spec.rb
r509-1.0 spec/crl/sqlite_reader_writer_spec.rb