summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/api/cert_test.rb1
-rw-r--r--test/integration/api/smtp_cert_test.rb12
-rw-r--r--test/integration/api/srp_test.rb9
-rw-r--r--test/integration/browser/account_test.rb36
4 files changed, 37 insertions, 21 deletions
diff --git a/test/integration/api/cert_test.rb b/test/integration/api/cert_test.rb
index 118fb9f..772901d 100644
--- a/test/integration/api/cert_test.rb
+++ b/test/integration/api/cert_test.rb
@@ -2,6 +2,7 @@ require 'test_helper'
class CertTest < ApiIntegrationTest
+
test "retrieve eip cert" do
login
get '/1/cert', {}, RACK_ENV
diff --git a/test/integration/api/smtp_cert_test.rb b/test/integration/api/smtp_cert_test.rb
index 2f50ef3..681d509 100644
--- a/test/integration/api/smtp_cert_test.rb
+++ b/test/integration/api/smtp_cert_test.rb
@@ -3,8 +3,13 @@ require 'openssl'
class SmtpCertTest < ApiIntegrationTest
+ setup do
+ @testcode = InviteCode.new
+ @testcode.save!
+ end
+
test "retrieve smtp cert" do
- @user = FactoryGirl.create :user, effective_service_level_code: 2
+ @user = FactoryGirl.create :user, effective_service_level_code: 2, :invite_code => @testcode.invite_code
login
post '/1/smtp_cert', {}, RACK_ENV
assert_text_response
@@ -15,7 +20,7 @@ class SmtpCertTest < ApiIntegrationTest
end
test "cert and key" do
- @user = FactoryGirl.create :user, effective_service_level_code: 2
+ @user = FactoryGirl.create :user, effective_service_level_code: 2, :invite_code => @testcode.invite_code
login
post '/1/smtp_cert', {}, RACK_ENV
assert_text_response
@@ -27,7 +32,7 @@ class SmtpCertTest < ApiIntegrationTest
end
test "fingerprint is stored with identity" do
- @user = FactoryGirl.create :user, effective_service_level_code: 2
+ @user = FactoryGirl.create :user, effective_service_level_code: 2, :invite_code => @testcode.invite_code
login
post '/1/smtp_cert', {}, RACK_ENV
assert_text_response
@@ -41,6 +46,7 @@ class SmtpCertTest < ApiIntegrationTest
end
test "fetching smtp certs requires email account" do
+
login
post '/1/smtp_cert', {}, RACK_ENV
assert_access_denied
diff --git a/test/integration/api/srp_test.rb b/test/integration/api/srp_test.rb
index fbef47e..463abcd 100644
--- a/test/integration/api/srp_test.rb
+++ b/test/integration/api/srp_test.rb
@@ -1,5 +1,10 @@
class SrpTest < RackTest
+ setup do
+ @testcode = InviteCode.new
+ @testcode.save!
+ end
+
teardown do
if @user
cleanup_user
@@ -32,10 +37,10 @@ class SrpTest < RackTest
attr_reader :server_auth
- def register_user(login = "integration_test", password = 'srp, verify me!')
+ def register_user(login = "integration_test", password = 'srp, verify me!', invite_code = @testcode.invite_code)
cleanup_user(login)
post 'http://api.lvh.me:3000/1/users.json',
- user_params(login: login, password: password)
+ user_params(login: login, password: password, invite_code: invite_code)
assert(@user = User.find_by_login(login), 'user should have been created: %s' % last_response_errors)
@login = login
@password = password
diff --git a/test/integration/browser/account_test.rb b/test/integration/browser/account_test.rb
index aea5406..cbe7ba9 100644
--- a/test/integration/browser/account_test.rb
+++ b/test/integration/browser/account_test.rb
@@ -6,7 +6,7 @@ class AccountTest < BrowserIntegrationTest
Identity.destroy_all_disabled
end
- test "signup successfully" do
+ test "signup successfully when invited" do
username, password = submit_signup
assert page.has_content?("Welcome #{username}")
click_on 'Log Out'
@@ -16,6 +16,22 @@ class AccountTest < BrowserIntegrationTest
user.account.destroy
end
+ test "signup successfully without invitation" do
+ with_config invite_required: false do
+
+ username ||= "test_#{SecureRandom.urlsafe_base64}".downcase
+ password ||= SecureRandom.base64
+
+ visit '/users/new'
+ fill_in 'Username', with: username
+ fill_in 'Password', with: password
+ fill_in 'Password confirmation', with: password
+ click_on 'Sign Up'
+
+ assert page.has_content?("Welcome #{username}")
+ end
+ end
+
test "signup with username ending in dot json" do
username = Faker::Internet.user_name + '.json'
submit_signup username
@@ -47,6 +63,7 @@ class AccountTest < BrowserIntegrationTest
test "account destruction" do
username, password = submit_signup
+
click_on I18n.t('account_settings')
click_on I18n.t('destroy_my_account')
assert page.has_content?(I18n.t('account_destroyed'))
@@ -81,21 +98,6 @@ class AccountTest < BrowserIntegrationTest
end
end
- test "change password" do
- with_config user_actions: ['change_password'] do
- login
- click_on "Account Settings"
- within('#update_login_and_password') do
- fill_in 'Password', with: "other password"
- fill_in 'Password confirmation', with: "other password"
- click_on 'Save'
- end
- click_on 'Log Out'
- attempt_login(@user.login, "other password")
- assert page.has_content?("Welcome #{@user.login}")
- end
- end
-
test "change pgp key" do
with_config user_actions: ['change_pgp_key'] do
pgp_key = FactoryGirl.build :pgp_key
@@ -117,6 +119,8 @@ class AccountTest < BrowserIntegrationTest
# trying to seed an invalid A for srp login
test "detects attempt to circumvent SRP" do
+ InviteCodeValidator.any_instance.stubs(:validate)
+
user = FactoryGirl.create :user
visit '/login'
fill_in 'Username', with: user.login