Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e3a419aa
Commit
e3a419aa
authored
Dec 12, 2014
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kerberos: specs
parent
8a799319
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
spec/helpers/oauth_helper_spec.rb
spec/helpers/oauth_helper_spec.rb
+12
-0
spec/lib/gitlab/auth_spec.rb
spec/lib/gitlab/auth_spec.rb
+11
-0
spec/lib/gitlab/kerberos/authentication_spec.rb
spec/lib/gitlab/kerberos/authentication_spec.rb
+41
-0
No files found.
spec/helpers/oauth_helper_spec.rb
View file @
e3a419aa
...
@@ -17,4 +17,16 @@ describe OauthHelper do
...
@@ -17,4 +17,16 @@ describe OauthHelper do
helper
.
additional_providers
.
should
==
[]
helper
.
additional_providers
.
should
==
[]
end
end
end
end
describe
"kerberos_enabled?"
do
it
'returns true'
do
allow
(
helper
).
to
receive
(
:enabled_oauth_providers
)
{
[
:twitter
,
:github
,
:kerberos
]
}
helper
.
kerberos_enabled?
.
should
be_true
end
it
'returns false'
do
allow
(
helper
).
to
receive
(
:enabled_oauth_providers
)
{
[
:twitter
,
:ldapmain
]
}
helper
.
kerberos_enabled?
.
should
be_false
end
end
end
end
\ No newline at end of file
spec/lib/gitlab/auth_spec.rb
View file @
e3a419aa
...
@@ -35,6 +35,17 @@ describe Gitlab::Auth do
...
@@ -35,6 +35,17 @@ describe Gitlab::Auth do
expect
(
gl_auth
.
find
(
username
,
password
)
).
to_not
eql
user
expect
(
gl_auth
.
find
(
username
,
password
)
).
to_not
eql
user
end
end
context
"with kerberos"
do
before
{
Devise
.
stub
(
omniauth_providers:
[
:kerberos
])
}
it
"finds user"
do
Gitlab
::
Kerberos
::
Authentication
.
stub
(
valid?:
true
)
Gitlab
::
Kerberos
::
Authentication
.
stub
(
email:
user
.
email
)
expect
(
gl_auth
.
find
(
username
,
password
)
).
to
eql
user
end
end
context
"with ldap enabled"
do
context
"with ldap enabled"
do
before
{
Gitlab
::
LDAP
::
Config
.
stub
(
enabled?:
true
)
}
before
{
Gitlab
::
LDAP
::
Config
.
stub
(
enabled?:
true
)
}
...
...
spec/lib/gitlab/kerberos/authentication_spec.rb
0 → 100644
View file @
e3a419aa
require
'spec_helper'
describe
Gitlab
::
Kerberos
::
Authentication
do
let
(
:klass
)
{
Gitlab
::
Kerberos
::
Authentication
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:login
)
{
'john'
}
let
(
:password
)
{
'password'
}
describe
:login
do
before
do
Devise
.
stub
(
omniauth_providers:
[
:kerberos
])
end
it
"finds the user if authentication is successful"
do
kerberos_login
=
user
.
email
.
sub
(
/@.*/
,
''
)
kerberos_realm
=
user
.
email
.
sub
(
/.*@/
,
''
)
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_init_creds_password:
true
)
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_default_realm:
kerberos_realm
)
expect
(
klass
.
login
(
kerberos_login
,
password
)).
to
be_true
end
it
"returns false if there is no such user in kerberos"
do
kerberos_login
=
"some-login"
kerberos_realm
=
user
.
email
.
sub
(
/.*@/
,
''
)
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_init_creds_password:
true
)
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_default_realm:
kerberos_realm
)
expect
(
klass
.
login
(
kerberos_login
,
password
)).
to
be_false
end
it
"returns false if kerberos user is valid but system has wrong realm"
do
kerberos_login
=
user
.
email
.
sub
(
/@.*/
,
''
)
kerberos_realm
=
"some-realm.com"
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_init_creds_password:
true
)
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_default_realm:
kerberos_realm
)
expect
(
klass
.
login
(
kerberos_login
,
password
)).
to
be_false
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment