File: sub_key_test.rb

package info (click to toggle)
ruby-gpgme 2.0.23-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,920 kB
  • sloc: ruby: 3,129; ansic: 2,559; sh: 7; makefile: 5
file content (51 lines) | stat: -rw-r--r-- 1,236 bytes parent folder | download | duplicates (3)
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
49
50
51
# -*- encoding: utf-8 -*-
require 'test_helper'

describe GPGME::SubKey do
  before do
    skip unless ensure_keys 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
      key = GPGME::Key.find(:secret, EXPIRED_KEY[:sha]).first
      if key
        subkey = key.primary_subkey
        assert subkey.expired
      end
    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