Sha256: ceac3764e8f61e4143bb5df5c735737d4ca891b02c43c3067838a741e3b824fe

Contents?: true

Size: 1.29 KB

Versions: 19

Compression:

Stored size: 1.29 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

module Gritano
  describe Key do
    
    def create_new_user_and_key
      user = User.create(login: "igor")
      key = user.keys.create(name: "mykey", key: "sshkey")
      return user, key
    end
    
    it "should have a name" do
      key = Gritano::Key.new(key: "key")
      key.should be_invalid
    end
    
    it "should have a ssh key" do
      key = Gritano::Key.new(name: "name")
      key.should be_invalid
    end
    
    it "should have a unique name per user" do
      user, key = create_new_user_and_key
      user.keys.create(name: "mykey", key: "sshkey").should be_invalid
      user.keys.count.should == 1
    end
    
    it "should belongs to a user" do
      user, key = create_new_user_and_key
      key.user.should == user
    end
    
    it "should generate the authorized_keys files if ssh's configurations is false" do
      create_new_user_and_key
      Key.authorized_keys.should == "command=\"gritano-remote igor\" sshkey\n\n"
    end
    
    it "should not generate the authorized_keys files if ssh's configurations is true" do
      user, key = create_new_user_and_key
      Key.config = YAML::load(File.open(File.join('features', 'data', 'config_true.yml')))
      Key.authorized_keys.should == ""
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gritano-1.0.0 spec/model_key_spec.rb
gritano-0.11.2 spec/model_key_spec.rb
gritano-0.11.1 spec/model_key_spec.rb
gritano-0.11.0 spec/model_key_spec.rb
gritano-0.10.3 spec/model_key_spec.rb
gritano-0.10.2 spec/model_key_spec.rb
gritano-0.10.1 spec/model_key_spec.rb
gritano-0.10.0 spec/model_key_spec.rb
gritano-0.9.4 spec/model_key_spec.rb
gritano-0.9.3 spec/model_key_spec.rb
gritano-0.9.2 spec/model_key_spec.rb
gritano-0.9.1 spec/model_key_spec.rb
gritano-0.9.0 spec/model_key_spec.rb
gritano-0.8.1 spec/model_key_spec.rb
gritano-0.8.0 spec/model_key_spec.rb
gritano-0.7.2 spec/model_key_spec.rb
gritano-0.7.1 spec/model_key_spec.rb
gritano-0.7.0 spec/model_key_spec.rb
gritano-0.6.0 spec/model_key_spec.rb