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
0d66c970
Commit
0d66c970
authored
May 06, 2021
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for git actions
parent
503150b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
+74
-0
ee/spec/models/ee/user_spec.rb
ee/spec/models/ee/user_spec.rb
+38
-0
ee/spec/requests/git_http_spec.rb
ee/spec/requests/git_http_spec.rb
+36
-0
No files found.
ee/spec/models/ee/user_spec.rb
View file @
0d66c970
...
...
@@ -919,6 +919,44 @@ RSpec.describe User do
end
end
describe
'#password_based_login_forbidden?'
do
context
'when user is provisioned by group'
do
before
do
user
.
user_detail
.
provisioned_by_group
=
build
(
:group
)
end
it
'is true'
do
expect
(
user
.
password_based_login_forbidden?
).
to
eq
true
end
context
'with feature flag switched off'
do
before
do
stub_feature_flags
(
block_password_auth_for_saml_users:
false
)
end
it
'is false'
do
expect
(
user
.
password_based_login_forbidden?
).
to
eq
false
end
end
end
context
'when user is not provisioned by group'
do
it
'is false'
do
expect
(
user
.
password_based_login_forbidden?
).
to
eq
false
end
context
'with feature flag switched off'
do
before
do
stub_feature_flags
(
block_password_auth_for_saml_users:
false
)
end
it
'is false'
do
expect
(
user
.
password_based_login_forbidden?
).
to
eq
false
end
end
end
end
describe
'#using_license_seat?'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
ee/spec/requests/git_http_spec.rb
View file @
0d66c970
...
...
@@ -153,4 +153,40 @@ RSpec.describe 'Git HTTP requests' do
it_behaves_like
'pulls are allowed'
end
describe
'when user cannot use password-based login'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:private
,
group:
group
)
}
let
(
:env
)
{
{
user:
user
.
username
,
password:
user
.
password
}
}
let
(
:path
)
{
"
#{
project
.
full_path
}
.git"
}
before
do
project
.
add_developer
(
user
)
user
.
update!
(
provisioned_by_group:
group
)
end
context
'with feature flag switched off'
do
before
do
stub_feature_flags
(
block_password_auth_for_saml_users:
false
)
end
it_behaves_like
'pulls are allowed'
it_behaves_like
'pushes are allowed'
end
context
'with feature flag switched on'
do
it
'responds with status 401 Unauthorized for pull action'
do
download
(
path
,
**
env
)
do
|
response
|
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
it
'responds with status 401 Unauthorized for push action'
do
upload
(
path
,
**
env
)
do
|
response
|
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
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