Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
2a0be666
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2a0be666
编写于
7月 05, 2016
作者:
P
Patricio Cano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added a lot of stubbing to make sure OAUth requests are handled properly with 2FA
上级
eda20534
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
3 deletion
+30
-3
spec/features/login_spec.rb
spec/features/login_spec.rb
+18
-1
spec/spec_helper.rb
spec/spec_helper.rb
+1
-1
spec/support/login_helpers.rb
spec/support/login_helpers.rb
+10
-0
spec/support/omni_auth.rb
spec/support/omni_auth.rb
+1
-1
未找到文件。
spec/features/login_spec.rb
浏览文件 @
2a0be666
...
...
@@ -110,12 +110,29 @@ feature 'Login', feature: true do
end
context
'logging in via OAuth'
do
def
saml_config
OpenStruct
.
new
(
name:
'saml'
,
label:
'saml'
,
args:
{
assertion_consumer_service_url:
'https://localhost:3443/users/auth/saml/callback'
,
idp_cert_fingerprint:
'26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52'
,
idp_sso_target_url:
'https://idp.example.com/sso/saml'
,
issuer:
'https://localhost:3443/'
,
name_identifier_format:
'urn:oasis:names:tc:SAML:2.0:nameid-format:transient'
})
end
def
stub_omniauth_config
(
messages
)
Rails
.
application
.
env_config
[
'devise.mapping'
]
=
Devise
.
mappings
[
:user
]
Rails
.
application
.
routes
.
disable_clear_and_finalize
=
true
Rails
.
application
.
routes
.
draw
do
post
'/users/auth/saml'
=>
'omniauth_callbacks#saml'
end
allow
(
Gitlab
::
OAuth
::
Provider
).
to
receive_messages
(
providers:
[
:saml
],
config_for:
saml_config
)
allow
(
Gitlab
.
config
.
omniauth
).
to
receive_messages
(
messages
)
allow_any_instance_of
(
Object
).
to
receive
(
:user_omniauth_authorize_path
).
with
(
'saml'
).
and_return
(
'/users/auth/saml'
)
end
it
'should show 2FA prompt after OAuth login'
do
stub_omniauth_config
(
enabled:
true
,
auto_link_saml_user:
true
,
allow_single_sign_on:
[
'saml'
],
providers:
[
OpenStruct
.
new
(
name:
'saml'
,
label:
'saml'
,
args:
{})
])
stub_omniauth_config
(
enabled:
true
,
auto_link_saml_user:
true
,
allow_single_sign_on:
[
'saml'
],
providers:
[
saml_config
])
user
=
create
(
:omniauth_user
,
:two_factor
,
extern_uid:
'my-uid'
,
provider:
'saml'
)
login_via
(
'saml'
,
user
,
'my-uid'
)
...
...
spec/spec_helper.rb
浏览文件 @
2a0be666
...
...
@@ -56,4 +56,4 @@ FactoryGirl::SyntaxRunner.class_eval do
include
RSpec
::
Mocks
::
ExampleMethods
end
ActiveRecord
::
Migration
.
maintain_test_schema!
\ No newline at end of file
ActiveRecord
::
Migration
.
maintain_test_schema!
spec/support/login_helpers.rb
浏览文件 @
2a0be666
...
...
@@ -39,6 +39,7 @@ module LoginHelpers
def
login_via
(
provider
,
user
,
uid
)
mock_auth_hash
(
provider
,
uid
,
user
.
email
)
Rails
.
application
.
env_config
[
'omniauth.auth'
]
=
OmniAuth
.
config
.
mock_auth
[
:saml
]
visit
new_user_session_path
click_link
provider
end
...
...
@@ -57,6 +58,15 @@ module LoginHelpers
credentials:
{
token:
'mock_token'
,
secret:
'mock_secret'
},
extra:
{
raw_info:
{
info:
{
name:
'mockuser'
,
email:
email
,
image:
'mock_user_thumbnail_url'
}
}
}
})
end
...
...
spec/support/omni_auth.rb
浏览文件 @
2a0be666
OmniAuth
.
config
.
test_mode
=
true
\ No newline at end of file
OmniAuth
.
config
.
test_mode
=
true
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录