summaryrefslogtreecommitdiff
path: root/test/integration/api/pgp_key_test.rb
blob: 4c7fb4c73069cd7677bb4efd40699dff1d2bf584 (plain)
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
require 'test_helper'
require_relative 'srp_test'

class PgpKeyTest < SrpTest

  setup do
    # todo: prepare user and login without doing the srp dance
    register_user
    authenticate
  end

  test "upload pgp key" do
    update_user public_key: key
    assert_equal key, Identity.for(@user).keys[:pgp]
  end

  # eventually probably want to remove most of this into a non-integration
  # functional test
  test "prevent uploading invalid key" do
    update_user public_key: "invalid key"
    assert_nil Identity.for(@user).keys[:pgp]
  end

  test "prevent emptying public key" do
    update_user public_key: key
    update_user public_key: ""
    assert_equal key, Identity.for(@user).keys[:pgp]
  end

  protected

  def key
    @key ||= FactoryGirl.build :pgp_key
  end
end