diff options
author | Johannes Schleifenbaum <johannes@js-webcoding.de> | 2014-02-11 22:15:13 +0400 |
---|---|---|
committer | Johannes Schleifenbaum <johannes@js-webcoding.de> | 2014-02-11 22:24:23 +0400 |
commit | f10153818b51da7ee4e691cea308dd8964d908c9 (patch) | |
tree | 102a2b88fe9f029a2c4ef3cb6b3e1a1c5ab8a338 /spec | |
parent | 39aeac71b34648d8c691ff36f577bdacbd3e362f (diff) |
Split the user ssh keys by newline, not the characters "\n"
before:
GET /user.keys
ssh-rsa ...\nssh-rsa ...\nssh-rsa ...
after:
GET /user.keys
ssh-rsa ...
ssh-rsa ...
sha-rsa ...
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/profile_keys_controller_spec.rb | 49 | ||||
-rw-r--r-- | spec/factories.rb | 6 |
2 files changed, 55 insertions, 0 deletions
diff --git a/spec/controllers/profile_keys_controller_spec.rb b/spec/controllers/profile_keys_controller_spec.rb new file mode 100644 index 00000000000..121012d5d49 --- /dev/null +++ b/spec/controllers/profile_keys_controller_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe Profiles::KeysController do + let(:user) { create(:user) } + + describe "#get_keys" do + describe "non existant user" do + it "should generally not work" do + get :get_keys, username: 'not-existent' + + expect(response).not_to be_success + end + end + + describe "user with no keys" do + it "should generally work" do + get :get_keys, username: user.username + + expect(response).to be_success + end + + it "should render all keys separated with a new line" do + get :get_keys, username: user.username + + expect(response.body).to eq("") + end + end + + describe "user with keys" do + before do + user.keys << create(:key) + user.keys << create(:another_key) + end + + it "should generally work" do + get :get_keys, username: user.username + + expect(response).to be_success + end + + it "should render all keys separated with a new line" do + get :get_keys, username: user.username + + expect(response.body).not_to eq("") + expect(response.body).to eq(user.all_ssh_keys.join("\n")) + end + end + end +end diff --git a/spec/factories.rb b/spec/factories.rb index 8c12c9b3e19..e5d05a4c2ea 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -207,6 +207,12 @@ FactoryGirl.define do end end + factory :another_key do + key do + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmTillFzNTrrGgwaCKaSj+QCz81E6jBc/s9av0+3b1Hwfxgkqjl4nAK/OD2NjgyrONDTDfR8cRN4eAAy6nY8GLkOyYBDyuc5nTMqs5z3yVuTwf3koGm/YQQCmo91psZ2BgDFTor8SVEE5Mm1D1k3JDMhDFxzzrOtRYFPci9lskTJaBjpqWZ4E9rDTD2q/QZntCqbC3wE9uSemRQB5f8kik7vD/AD8VQXuzKladrZKkzkONCPWsXDspUitjM8HkQdOf0PsYn1CMUC1xKYbCxkg5TkEosIwGv6CoEArUrdu/4+10LVslq494mAvEItywzrluCLCnwELfW+h/m8UHoVhZ" + end + end + factory :invalid_key do key do "ssh-rsa this_is_invalid_key==" |