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
4643d944
Commit
4643d944
authored
Oct 02, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix after code review
parent
95ed2c38
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
21 deletions
+28
-21
db/schema.rb
db/schema.rb
+1
-1
ee/app/helpers/feature_flags_helper.rb
ee/app/helpers/feature_flags_helper.rb
+4
-2
ee/app/views/projects/feature_flags/_configure_feature_flags_modal.html.haml
...ts/feature_flags/_configure_feature_flags_modal.html.haml
+1
-1
ee/app/views/projects/feature_flags/_errors.html.haml
ee/app/views/projects/feature_flags/_errors.html.haml
+2
-2
ee/db/migrate/20180626171125_add_feature_flags_to_projects.rb
...b/migrate/20180626171125_add_feature_flags_to_projects.rb
+1
-1
ee/lib/api/unleash.rb
ee/lib/api/unleash.rb
+11
-6
ee/spec/controllers/projects/feature_flags_controller_spec.rb
...pec/controllers/projects/feature_flags_controller_spec.rb
+1
-1
ee/spec/helpers/feature_flags_helper_spec.rb
ee/spec/helpers/feature_flags_helper_spec.rb
+2
-2
ee/spec/requests/api/unleash_spec.rb
ee/spec/requests/api/unleash_spec.rb
+5
-5
No files found.
db/schema.rb
View file @
4643d944
...
@@ -1959,7 +1959,7 @@ ActiveRecord::Schema.define(version: 20180926140319) do
...
@@ -1959,7 +1959,7 @@ ActiveRecord::Schema.define(version: 20180926140319) do
t
.
string
"token"
,
null:
false
t
.
string
"token"
,
null:
false
end
end
add_index
"operations_feature_flags_clients"
,
[
"
token"
],
name:
"index_operations_feature_flags_clients_on
_token"
,
unique:
true
,
using: :btree
add_index
"operations_feature_flags_clients"
,
[
"
project_id"
,
"token"
],
name:
"index_operations_feature_flags_clients_on_project_id_and
_token"
,
unique:
true
,
using: :btree
create_table
"packages_maven_metadata"
,
id: :bigserial
,
force: :cascade
do
|
t
|
create_table
"packages_maven_metadata"
,
id: :bigserial
,
force: :cascade
do
|
t
|
t
.
integer
"package_id"
,
limit:
8
,
null:
false
t
.
integer
"package_id"
,
limit:
8
,
null:
false
...
...
ee/app/helpers/feature_flags_helper.rb
View file @
4643d944
# frozen_string_literal: true
# frozen_string_literal: true
module
FeatureFlagsHelper
module
FeatureFlagsHelper
include
::
API
::
Helpers
::
RelatedResourcesHelpers
def
unleash_api_url
(
project
)
def
unleash_api_url
(
project
)
"
#{
root_url
(
only_path:
false
)
}
api/v4/feature_flags/unleash/
#{
project
.
id
}
"
expose_url
(
api_v4_feature_flags_unleash_path
(
project_id:
project
.
id
))
end
end
def
unleash_api_instanceid
(
project
)
def
unleash_api_instance
_
id
(
project
)
project
.
feature_flags_client_token
project
.
feature_flags_client_token
end
end
end
end
ee/app/views/projects/feature_flags/_configure_feature_flags_modal.html.haml
View file @
4643d944
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
=
label_tag
:instance_id
,
s_
(
'FeatureFlags|Instance ID'
),
class:
'label-bold'
=
label_tag
:instance_id
,
s_
(
'FeatureFlags|Instance ID'
),
class:
'label-bold'
.input-group
.input-group
=
text_field_tag
:instance_id
,
=
text_field_tag
:instance_id
,
unleash_api_instanceid
(
@project
),
unleash_api_instance
_
id
(
@project
),
readonly:
true
,
readonly:
true
,
class:
"form-control js-select-on-focus"
class:
"form-control js-select-on-focus"
%span
.input-group-append
%span
.input-group-append
...
...
ee/app/views/projects/feature_flags/_errors.html.haml
View file @
4643d944
#error_explanation
#error_explanation
.alert.alert-danger
.alert.alert-danger
-
@feature_flag
.
errors
.
full_messages
.
each
do
|
m
sg
|
-
@feature_flag
.
errors
.
full_messages
.
each
do
|
m
essage
|
%p
=
m
sg
%p
=
m
essage
ee/db/migrate/20180626171125_add_feature_flags_to_projects.rb
View file @
4643d944
...
@@ -23,7 +23,7 @@ class AddFeatureFlagsToProjects < ActiveRecord::Migration
...
@@ -23,7 +23,7 @@ class AddFeatureFlagsToProjects < ActiveRecord::Migration
t
.
integer
:project_id
,
null:
false
t
.
integer
:project_id
,
null:
false
t
.
string
:token
,
null:
false
t
.
string
:token
,
null:
false
t
.
index
:token
,
unique:
true
t
.
index
[
:project_id
,
:token
]
,
unique:
true
t
.
foreign_key
:projects
,
column: :project_id
,
on_delete: :cascade
t
.
foreign_key
:projects
,
column: :project_id
,
on_delete: :cascade
end
end
...
...
ee/lib/api/unleash.rb
View file @
4643d944
...
@@ -6,14 +6,19 @@ module API
...
@@ -6,14 +6,19 @@ module API
resource
:unleash
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
resource
:unleash
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
params
do
params
do
requires
:project_id
,
type:
String
,
desc:
'The ID of a project'
requires
:project_id
,
type:
String
,
desc:
'The ID of a project'
optional
:instanceid
,
type:
String
,
desc:
'The Instance ID of Unleash Client'
optional
:instance
_
id
,
type:
String
,
desc:
'The Instance ID of Unleash Client'
end
end
route_param
:project_id
do
route_param
:project_id
do
before
do
before
do
authorize_by_unleash_instanceid!
authorize_by_unleash_instance
_
id!
authorize_feature_flags_feature!
authorize_feature_flags_feature!
end
end
get
do
# not supported yet
status
:ok
end
get
'features'
do
get
'features'
do
present
project
,
with:
::
EE
::
API
::
Entities
::
UnleashFeatures
present
project
,
with:
::
EE
::
API
::
Entities
::
UnleashFeatures
end
end
...
@@ -36,13 +41,13 @@ module API
...
@@ -36,13 +41,13 @@ module API
@project
||=
find_project
(
params
[
:project_id
])
@project
||=
find_project
(
params
[
:project_id
])
end
end
def
unleash_instanceid
def
unleash_instance
_
id
params
[
:instanceid
]
||
env
[
'HTTP_UNLEASH_INSTANCEID'
]
params
[
:instance
_
id
]
||
env
[
'HTTP_UNLEASH_INSTANCEID'
]
end
end
def
authorize_by_unleash_instanceid!
def
authorize_by_unleash_instance
_
id!
unauthorized!
unless
Operations
::
FeatureFlagsClient
unauthorized!
unless
Operations
::
FeatureFlagsClient
.
find_for_project_and_token
(
project
,
unleash_instanceid
)
.
find_for_project_and_token
(
project
,
unleash_instance
_
id
)
end
end
def
authorize_feature_flags_feature!
def
authorize_feature_flags_feature!
...
...
ee/spec/controllers/projects/feature_flags_controller_spec.rb
View file @
4643d944
require
'spec_helper'
require
'spec_helper'
describe
Projects
::
FeatureFlagsController
do
describe
Projects
::
FeatureFlagsController
do
include
Rails
.
application
.
routes
.
url_helpers
include
Gitlab
::
Routing
set
(
:user
)
{
create
(
:user
)
}
set
(
:user
)
{
create
(
:user
)
}
set
(
:project
)
{
create
(
:project
)
}
set
(
:project
)
{
create
(
:project
)
}
...
...
ee/spec/helpers/feature_flags_helper_spec.rb
View file @
4643d944
...
@@ -9,8 +9,8 @@ describe FeatureFlagsHelper do
...
@@ -9,8 +9,8 @@ describe FeatureFlagsHelper do
it
{
is_expected
.
to
end_with
(
"/api/v4/feature_flags/unleash/
#{
project
.
id
}
"
)
}
it
{
is_expected
.
to
end_with
(
"/api/v4/feature_flags/unleash/
#{
project
.
id
}
"
)
}
end
end
context
'#unleash_api_instanceid'
do
context
'#unleash_api_instance
_
id'
do
subject
{
helper
.
unleash_api_instanceid
(
project
)
}
subject
{
helper
.
unleash_api_instance
_
id
(
project
)
}
it
{
is_expected
.
not_to
be_empty
}
it
{
is_expected
.
not_to
be_empty
}
end
end
...
...
ee/spec/requests/api/unleash_spec.rb
View file @
4643d944
...
@@ -12,9 +12,9 @@ describe API::Unleash do
...
@@ -12,9 +12,9 @@ describe API::Unleash do
end
end
shared_examples
'authenticated request'
do
shared_examples
'authenticated request'
do
context
'when using instanceid'
do
context
'when using instance
id'
do
let
(
:client
)
{
create
(
:operations_feature_flags_client
,
project:
project
)
}
let
(
:client
)
{
create
(
:operations_feature_flags_client
,
project:
project
)
}
let
(
:params
)
{
{
instanceid:
client
.
token
}
}
let
(
:params
)
{
{
instance
_
id:
client
.
token
}
}
it
'responds with OK'
do
it
'responds with OK'
do
subject
subject
...
@@ -44,8 +44,8 @@ describe API::Unleash do
...
@@ -44,8 +44,8 @@ describe API::Unleash do
end
end
end
end
context
'when using bogus instanceid'
do
context
'when using bogus instance
id'
do
let
(
:params
)
{
{
instanceid:
'token'
}
}
let
(
:params
)
{
{
instance
_
id:
'token'
}
}
it
'responds with unauthorized'
do
it
'responds with unauthorized'
do
subject
subject
...
@@ -56,7 +56,7 @@ describe API::Unleash do
...
@@ -56,7 +56,7 @@ describe API::Unleash do
context
'when using not existing project'
do
context
'when using not existing project'
do
let
(
:project_id
)
{
-
5000
}
let
(
:project_id
)
{
-
5000
}
let
(
:params
)
{
{
instanceid:
'token'
}
}
let
(
:params
)
{
{
instance
_
id:
'token'
}
}
it
'responds with unauthorized'
do
it
'responds with unauthorized'
do
subject
subject
...
...
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