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
99ffb093
Commit
99ffb093
authored
Feb 28, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for LDAP person SSH keys.
parent
4a8a2f80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
spec/lib/gitlab/ldap/person_spec.rb
spec/lib/gitlab/ldap/person_spec.rb
+74
-0
No files found.
spec/lib/gitlab/ldap/person_spec.rb
0 → 100644
View file @
99ffb093
require
"spec_helper"
describe
Gitlab
::
LDAP
::
Person
do
describe
"#ssh_keys"
do
let
(
:ssh_key
)
{
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrSQHff6a1rMqBdHFt+FwIbytMZ+hJKN3KLkTtOWtSvNIriGhnTdn4rs+tjD/w+z+revytyWnMDM9dS7J8vQi006B16+hc9Xf82crqRoPRDnBytgAFFQY1G/55ql2zdfsC5yvpDOFzuwIJq5dNGsojS82t6HNmmKPq130fzsenFnj5v1pl3OJvk513oduUyKiZBGTroWTn7H/eOPtu7s9MD7pAdEjqYKFLeaKmyidiLmLqQlCRj3Tl2U9oyFg4PYNc0bL5FZJ/Z6t0Ds3i/a2RanQiKxrvgu3GSnUKMx7WIX373baL4jeM7cprRGiOY/1NcS+1cAjfJ8oaxQF/1dYj"
}
let
(
:ssh_key_attribute_name
)
{
'altSecurityIdentities'
}
let
(
:entry
)
{
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
"dn: cn=foo, dc=bar, dc=com
\n
#{
keys
}
"
)
}
subject
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
before
do
Gitlab
::
LDAP
::
Config
.
any_instance
.
stub
(
sync_ssh_keys:
ssh_key_attribute_name
)
end
context
"when the SSH key is literal"
do
let
(
:keys
)
{
"
#{
ssh_key_attribute_name
}
:
#{
ssh_key
}
"
}
it
"includes the SSH key"
do
expect
(
subject
.
ssh_keys
).
to
include
(
ssh_key
)
end
end
context
"when the SSH key is prefixed"
do
let
(
:keys
)
{
"
#{
ssh_key_attribute_name
}
: SSHKey:
#{
ssh_key
}
"
}
it
"includes the SSH key"
do
expect
(
subject
.
ssh_keys
).
to
include
(
ssh_key
)
end
end
context
"when the SSH key is suffixed"
do
let
(
:keys
)
{
"
#{
ssh_key_attribute_name
}
:
#{
ssh_key
}
(SSH key)"
}
it
"includes the SSH key"
do
expect
(
subject
.
ssh_keys
).
to
include
(
ssh_key
)
end
end
context
"when the SSH key is followed by a newline"
do
let
(
:keys
)
{
"
#{
ssh_key_attribute_name
}
:
#{
ssh_key
}
\n
"
}
it
"includes the SSH key"
do
expect
(
subject
.
ssh_keys
).
to
include
(
ssh_key
)
end
end
context
"when the key is not an SSH key"
do
let
(
:keys
)
{
"
#{
ssh_key_attribute_name
}
: KerberosKey:bogus"
}
it
"is empty"
do
expect
(
subject
.
ssh_keys
).
to
be_empty
end
end
context
"when there are multiple keys"
do
let
(
:keys
)
{
"
#{
ssh_key_attribute_name
}
:
#{
ssh_key
}
\n
#{
ssh_key_attribute_name
}
: KerberosKey:bogus
\n
#{
ssh_key_attribute_name
}
: ssh-rsa keykeykey"
}
it
"includes both SSH keys"
do
expect
(
subject
.
ssh_keys
).
to
include
(
ssh_key
)
expect
(
subject
.
ssh_keys
).
to
include
(
"ssh-rsa keykeykey"
)
expect
(
subject
.
ssh_keys
).
not_to
include
(
"KerberosKey:bogus"
)
end
end
end
end
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