File: sub_key_test.rb

package info (click to toggle)
ruby-gpgme 2.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,348 kB
  • ctags: 342
  • sloc: ruby: 2,921; ansic: 2,259; makefile: 3
file content (48 lines) | stat: -rw-r--r-- 1,209 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- encoding: utf-8 -*-
require 'test_helper'

describe GPGME::SubKey do
  before do
    skip unless GPGME::Engine.check_version GPGME::PROTOCOL_OpenPGP
  end

  # We trust Key for common methods that come from KeyCommon

  it "has certain attributes" do
    subkey = GPGME::Key.find(:secret).first.primary_subkey
    [:pubkey_algo, :length, :keyid, :fpr, :fingerprint].each do |attrib|
      assert subkey.respond_to?(attrib), "Key doesn't respond to #{attrib}"
    end
  end

  it "won't allow the creation of GPGME::SubKey's without the C API" do
    assert_raises NoMethodError do
      GPGME::SubKey.new
    end
  end

  it "knows if the key is expired" do
    subkey = GPGME::Key.find(:secret).first.primary_subkey
    refute subkey.expired

    with_key EXPIRED_KEY do
      subkey = GPGME::Key.find(:secret, EXPIRED_KEY[:sha]).first.primary_subkey
      assert subkey.expired
    end
  end

  describe :inspect do
    it "can be inspected" do
      subkey = GPGME::Key.find(:secret).first.primary_subkey
      subkey.inspect
    end
  end

  describe :to_s do
    it "can be coerced into a String" do
      subkey = GPGME::Key.find(:secret).first.primary_subkey
      subkey.to_s
    end
  end

end