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
ed0395e8
Commit
ed0395e8
authored
May 18, 2020
by
Adrien Kohlbecker
Committed by
Dylan Griffith
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add suggested specs on developper access to logs
parent
dbe3821d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
78 deletions
+139
-78
ee/spec/serializers/clusters/environment_entity_spec.rb
ee/spec/serializers/clusters/environment_entity_spec.rb
+35
-23
spec/controllers/projects/logs_controller_spec.rb
spec/controllers/projects/logs_controller_spec.rb
+66
-43
spec/serializers/environment_entity_spec.rb
spec/serializers/environment_entity_spec.rb
+38
-12
No files found.
ee/spec/serializers/clusters/environment_entity_spec.rb
View file @
ed0395e8
...
...
@@ -18,6 +18,7 @@ describe Clusters::EnvironmentEntity do
subject
{
described_class
.
new
(
environment
,
request:
request
).
as_json
}
context
'with maintainer access'
do
before
do
group
.
add_maintainer
(
user
)
end
...
...
@@ -55,4 +56,15 @@ describe Clusters::EnvironmentEntity do
expect
(
subject
).
to
include
(
:logs_path
)
end
end
context
'with developer access'
do
before
do
group
.
add_developer
(
user
)
end
it
'does not expose logs_path'
do
expect
(
subject
).
not_to
include
(
:logs_path
)
end
end
end
end
spec/controllers/projects/logs_controller_spec.rb
View file @
ed0395e8
...
...
@@ -16,16 +16,23 @@ describe Projects::LogsController do
let
(
:container
)
{
'container-1'
}
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
end
describe
'GET #index'
do
let
(
:empty_project
)
{
create
(
:project
)
}
it
'returns 404 with developer access'
do
project
.
add_developer
(
user
)
get
:index
,
params:
environment_params
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
it
'renders empty logs page if no environment exists'
do
empty_project
.
add_maintainer
(
user
)
get
:index
,
params:
{
namespace_id:
empty_project
.
namespace
,
project_id:
empty_project
}
expect
(
response
).
to
be_ok
...
...
@@ -33,6 +40,8 @@ describe Projects::LogsController do
end
it
'renders index template'
do
project
.
add_maintainer
(
user
)
get
:index
,
params:
environment_params
expect
(
response
).
to
be_ok
...
...
@@ -60,6 +69,19 @@ describe Projects::LogsController do
end
end
it
'returns 404 with developer access'
do
project
.
add_developer
(
user
)
get
endpoint
,
params:
environment_params
(
pod_name:
pod_name
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
context
'with maintainer access'
do
before
do
project
.
add_maintainer
(
user
)
end
it
'returns the service result'
do
get
endpoint
,
params:
environment_params
(
pod_name:
pod_name
,
format: :json
)
...
...
@@ -126,6 +148,7 @@ describe Projects::LogsController do
it_behaves_like
'unsuccessful execution response'
,
'Environment does not have deployments'
end
end
end
describe
'GET #k8s'
do
it_behaves_like
'pod logs service'
,
:k8s
,
PodLogs
::
KubernetesService
...
...
spec/serializers/environment_entity_spec.rb
View file @
ed0395e8
...
...
@@ -10,7 +10,13 @@ describe EnvironmentEntity do
described_class
.
new
(
environment
,
request:
spy
(
'request'
))
end
let
(
:environment
)
{
create
(
:environment
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
before
do
allow
(
entity
).
to
receive
(
:current_user
).
and_return
(
user
)
end
subject
{
entity
.
as_json
}
...
...
@@ -67,14 +73,33 @@ describe EnvironmentEntity do
end
context
'with auto_stop_in'
do
let
(
:environment
)
{
create
(
:environment
,
:will_auto_stop
)
}
let
(
:environment
)
{
create
(
:environment
,
:will_auto_stop
,
project:
project
)
}
it
'exposes auto stop related information'
do
project
.
add_maintainer
(
user
)
expect
(
subject
).
to
include
(
:cancel_auto_stop_path
,
:auto_stop_at
)
end
end
context
'pod_logs'
do
context
'with developer access'
do
before
do
project
.
add_developer
(
user
)
end
it
'does not expose logs keys'
do
expect
(
subject
).
not_to
include
(
:logs_path
)
expect
(
subject
).
not_to
include
(
:logs_api_path
)
expect
(
subject
).
not_to
include
(
:enable_advanced_logs_querying
)
end
end
context
'with maintainer access'
do
before
do
project
.
add_maintainer
(
user
)
end
it
'exposes logs keys'
do
expect
(
subject
).
to
include
(
:logs_path
)
expect
(
subject
).
to
include
(
:logs_api_path
)
...
...
@@ -82,13 +107,14 @@ describe EnvironmentEntity do
end
it
'uses k8s api when ES is not available'
do
expect
(
subject
[
:logs_api_path
]).
to
eq
(
k8s_project_logs_path
(
environment
.
project
,
environment_name:
environment
.
name
,
format: :json
))
expect
(
subject
[
:logs_api_path
]).
to
eq
(
k8s_project_logs_path
(
project
,
environment_name:
environment
.
name
,
format: :json
))
end
it
'uses ES api when ES is available'
do
allow
(
environment
).
to
receive
(
:elastic_stack_available?
).
and_return
(
true
)
expect
(
subject
[
:logs_api_path
]).
to
eq
(
elasticsearch_project_logs_path
(
environment
.
project
,
environment_name:
environment
.
name
,
format: :json
))
expect
(
subject
[
:logs_api_path
]).
to
eq
(
elasticsearch_project_logs_path
(
project
,
environment_name:
environment
.
name
,
format: :json
))
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