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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
23b692c7
Commit
23b692c7
authored
Oct 14, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for authentication and config
parent
fc5bfd1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
spec/lib/gitlab/ldap/authentication_spec.rb
spec/lib/gitlab/ldap/authentication_spec.rb
+53
-0
spec/lib/gitlab/ldap/config_spec.rb
spec/lib/gitlab/ldap/config_spec.rb
+20
-0
No files found.
spec/lib/gitlab/ldap/authentication_spec.rb
0 → 100644
View file @
23b692c7
require
'spec_helper'
describe
Gitlab
::
LDAP
::
Authentication
do
let
(
:klass
)
{
Gitlab
::
LDAP
::
Authentication
}
let
(
:user
)
{
create
(
:user
,
:ldap
,
extern_uid:
dn
)
}
let
(
:dn
)
{
'uid=john,ou=people,dc=example,dc=com'
}
let
(
:login
)
{
'john'
}
let
(
:password
)
{
'password'
}
describe
:login
do
let
(
:adapter
)
{
double
:adapter
}
before
do
Gitlab
::
LDAP
::
Config
.
stub
(
enabled?:
true
)
end
it
"finds the user if authentication is successful"
do
user
# try only to fake the LDAP call
klass
.
any_instance
.
stub
(
adapter:
double
(
:adapter
,
bind_as:
double
(
:ldap_user
,
dn:
dn
)
))
expect
(
klass
.
login
(
login
,
password
)).
to
be_true
end
it
"is false if the user does not exist"
do
# try only to fake the LDAP call
klass
.
any_instance
.
stub
(
adapter:
double
(
:adapter
,
bind_as:
double
(
:ldap_user
,
dn:
dn
)
))
expect
(
klass
.
login
(
login
,
password
)).
to
be_false
end
it
"is false if authentication fails"
do
user
# try only to fake the LDAP call
klass
.
any_instance
.
stub
(
adapter:
double
(
:adapter
,
bind_as:
nil
))
expect
(
klass
.
login
(
login
,
password
)).
to
be_false
end
it
"fails if ldap is disabled"
do
Gitlab
::
LDAP
::
Config
.
stub
(
enabled?:
false
)
expect
(
klass
.
login
(
login
,
password
)).
to
be_false
end
it
"fails if no login is supplied"
do
expect
(
klass
.
login
(
''
,
password
)).
to
be_false
end
it
"fails if no password is supplied"
do
expect
(
klass
.
login
(
login
,
''
)).
to
be_false
end
end
end
\ No newline at end of file
spec/lib/gitlab/ldap/config_spec.rb
0 → 100644
View file @
23b692c7
require
'spec_helper'
describe
Gitlab
::
LDAP
::
Config
do
let
(
:config
)
{
Gitlab
::
LDAP
::
Config
.
new
provider
}
let
(
:provider
)
{
'ldapmain'
}
describe
:initalize
do
it
'requires a provider'
do
expect
{
Gitlab
::
LDAP
::
Config
.
new
}.
to
raise_error
ArgumentError
end
it
"works"
do
expect
(
config
).
to
be_a
described_class
end
it
"raises an error if a unknow provider is used"
do
expect
{
Gitlab
::
LDAP
::
Config
.
new
'unknown'
}.
to
raise_error
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