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
6be18b98
Commit
6be18b98
authored
Dec 09, 2020
by
Mathieu Parent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure API exposes all project attributes
parent
f82bed31
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
199 additions
and
0 deletions
+199
-0
spec/requests/api/project_attributes.yml
spec/requests/api/project_attributes.yml
+149
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+50
-0
No files found.
spec/requests/api/project_attributes.yml
0 → 100644
View file @
6be18b98
---
itself
:
# project
unexposed_attributes
:
-
bfg_object_map
-
delete_error
-
detected_repository_languages
-
disable_overriding_approvers_per_merge_request
-
external_authorization_classification_label
-
external_webhook_token
-
has_external_issue_tracker
-
has_external_wiki
-
import_source
-
import_type
-
import_url
-
issues_template
-
jobs_cache_index
-
last_repository_check_at
-
last_repository_check_failed
-
last_repository_updated_at
-
marked_for_deletion_at
-
marked_for_deletion_by_user_id
-
max_artifacts_size
-
max_pages_size
-
merge_requests_author_approval
-
merge_requests_disable_committers_approval
-
merge_requests_rebase_enabled
-
merge_requests_template
-
mirror_last_successful_update_at
-
mirror_last_update_at
-
mirror_overwrites_diverged_branches
-
mirror_trigger_builds
-
mirror_user_id
-
only_mirror_protected_branches
-
pages_https_only
-
pending_delete
-
pool_repository_id
-
pull_mirror_available_overridden
-
pull_mirror_branch_prefix
-
remote_mirror_available_overridden
-
repository_read_only
-
repository_size_limit
-
require_password_to_approve
-
reset_approvals_on_push
-
runners_token_encrypted
-
storage_version
-
updated_at
remapped_attributes
:
avatar
:
avatar_url
build_allow_git_fetch
:
build_git_strategy
merge_requests_ff_only_enabled
:
merge_method
namespace_id
:
namespace
public_builds
:
public_jobs
visibility_level
:
visibility
computed_attributes
:
-
_links
-
can_create_merge_request_in
-
compliance_frameworks
-
container_expiration_policy
-
default_branch
-
empty_repo
-
forks_count
-
http_url_to_repo
-
name_with_namespace
-
open_issues_count
-
owner
-
path_with_namespace
-
permissions
-
readme_url
-
shared_with_groups
-
ssh_url_to_repo
-
web_url
build_auto_devops
:
# auto_devops
unexposed_attributes
:
-
id
-
project_id
-
created_at
-
updated_at
remapped_attributes
:
enabled
:
auto_devops_enabled
deploy_strategy
:
auto_devops_deploy_strategy
ci_cd_settings
:
unexposed_attributes
:
-
id
-
project_id
-
group_runners_enabled
-
keep_latest_artifact
-
merge_pipelines_enabled
-
merge_trains_enabled
-
auto_rollback_enabled
remapped_attributes
:
default_git_depth
:
ci_default_git_depth
forward_deployment_enabled
:
ci_forward_deployment_enabled
build_import_state
:
# import_state
unexposed_attributes
:
-
id
-
project_id
-
retry_count
-
last_update_started_at
-
last_update_scheduled_at
-
next_execution_timestamp
-
jid
-
last_update_at
-
last_successful_update_at
-
correlation_id_value
remapped_attributes
:
status
:
import_status
last_error
:
import_error
project_feature
:
unexposed_attributes
:
-
id
-
created_at
-
metrics_dashboard_access_level
-
project_id
-
requirements_access_level
-
security_and_compliance_access_level
-
updated_at
computed_attributes
:
-
issues_enabled
-
jobs_enabled
-
merge_requests_enabled
-
requirements_enabled
-
security_and_compliance_enabled
-
snippets_enabled
-
wiki_enabled
project_setting
:
unexposed_attributes
:
-
allow_editing_commit_messages
-
created_at
-
has_confluence
-
has_vulnerabilities
-
prevent_merge_without_jira_issue
-
project_id
-
push_rule_id
-
show_default_award_emojis
-
squash_option
-
updated_at
build_service_desk_setting
:
# service_desk_setting
unexposed_attributes
:
-
project_id
-
issue_template_key
-
outgoing_name
remapped_attributes
:
project_key
:
service_desk_address
spec/requests/api/projects_spec.rb
View file @
6be18b98
...
...
@@ -1539,6 +1539,35 @@ RSpec.describe API::Projects do
end
context
'when authenticated as an admin'
do
let
(
:project_attributes_file
)
{
'spec/requests/api/project_attributes.yml'
}
let
(
:project_attributes
)
{
YAML
.
load_file
(
project_attributes_file
)
}
let
(
:expected_keys
)
do
keys
=
project_attributes
.
map
do
|
relation
,
relation_config
|
begin
actual_keys
=
project
.
send
(
relation
).
attributes
.
keys
rescue
NoMethodError
actual_keys
=
[
"
#{
relation
}
is nil"
]
end
unexposed_attributes
=
relation_config
[
'unexposed_attributes'
]
||
[]
remapped_attributes
=
relation_config
[
'remapped_attributes'
]
||
{}
computed_attributes
=
relation_config
[
'computed_attributes'
]
||
[]
actual_keys
-
unexposed_attributes
-
remapped_attributes
.
keys
+
remapped_attributes
.
values
+
computed_attributes
end
.
flatten
unless
Gitlab
.
ee?
keys
-=
%w[
approvals_before_merge
compliance_frameworks
mirror
requirements_enabled
security_and_compliance_enabled
]
end
keys
end
it
'returns a project by id'
do
project
project_member
...
...
@@ -1587,6 +1616,27 @@ RSpec.describe API::Projects do
expect
(
json_response
[
'only_allow_merge_if_all_discussions_are_resolved'
]).
to
eq
(
project
.
only_allow_merge_if_all_discussions_are_resolved
)
expect
(
json_response
[
'operations_access_level'
]).
to
be_present
end
it
'exposes all necessary attributes'
do
create
(
:project_group_link
,
project:
project
)
get
api
(
"/projects/
#{
project
.
id
}
"
,
admin
)
diff
=
Set
.
new
(
json_response
.
keys
)
^
Set
.
new
(
expected_keys
)
expect
(
diff
).
to
be_empty
,
failure_message
(
diff
)
end
def
failure_message
(
diff
)
<<~
MSG
It looks like project's set of exposed attributes is different from the expected set.
The following attributes are missing or newly added:
#{
diff
.
to_a
.
to_sentence
}
Please update
#{
project_attributes_file
}
file"
MSG
end
end
context
'when authenticated as a regular user'
do
...
...
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