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
5316aa63
Commit
5316aa63
authored
Mar 11, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added repair authentication button for GeoNodes
parent
88af5b85
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
22 deletions
+34
-22
app/controllers/admin/geo_nodes_controller.rb
app/controllers/admin/geo_nodes_controller.rb
+14
-0
app/models/geo_node.rb
app/models/geo_node.rb
+1
-1
app/views/admin/geo_nodes/index.html.haml
app/views/admin/geo_nodes/index.html.haml
+4
-0
config/routes.rb
config/routes.rb
+5
-1
spec/models/geo_node_spec.rb
spec/models/geo_node_spec.rb
+10
-20
No files found.
app/controllers/admin/geo_nodes_controller.rb
View file @
5316aa63
...
...
@@ -22,6 +22,20 @@ class Admin::GeoNodesController < Admin::ApplicationController
redirect_to
admin_geo_nodes_path
,
notice:
'Node was successfully removed.'
end
def
repair
@node
=
GeoNode
.
find
(
params
[
:id
])
if
@node
.
primary?
||
!
@node
.
missing_oauth_application?
redirect_to
admin_geo_nodes_path
,
notice:
"This node doesn't need to be repaired."
elsif
@node
.
save
redirect_to
admin_geo_nodes_path
,
notice:
'Node Authentication was successfully repaired.'
else
redirect_to
admin_geo_nodes_path
,
alert:
'There was a problem repairing Node Authentication.'
end
end
private
def
geo_node_params
params
.
require
(
:geo_node
).
permit
(
:url
,
:primary
,
geo_node_key_attributes:
[
:key
])
end
...
...
app/models/geo_node.rb
View file @
5316aa63
...
...
@@ -72,7 +72,6 @@ class GeoNode < ActiveRecord::Base
def
build_dependents
self
.
build_geo_node_key
if
geo_node_key
.
nil?
self
.
build_oauth_application
if
oauth_application
.
nil?
end
def
update_dependents_attributes
...
...
@@ -81,6 +80,7 @@ class GeoNode < ActiveRecord::Base
if
self
.
primary?
self
.
oauth_application
=
nil
else
self
.
build_oauth_application
if
oauth_application
.
nil?
self
.
oauth_application
.
name
=
"Geo node:
#{
self
.
url
}
"
if
self
.
geo_node_key
self
.
oauth_application
.
redirect_uri
=
oauth_callback_url
end
...
...
app/views/admin/geo_nodes/index.html.haml
View file @
5316aa63
...
...
@@ -52,4 +52,8 @@
%span
.help-block
#{
node
.
primary
?
'Primary node'
:
'Secondary node'
}
.pull-right
-
if
node
.
missing_oauth_application?
=
link_to
repair_admin_geo_node_path
(
node
),
method: :post
,
class:
'btn btn-default, btn-sm'
do
=
icon
(
'exclamation-triangle fw'
)
Repair authentication
=
link_to
'Remove'
,
admin_geo_node_path
(
node
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
'btn btn-remove btn-sm'
config/routes.rb
View file @
5316aa63
...
...
@@ -282,7 +282,11 @@ Rails.application.routes.draw do
get
:download
,
on: :member
end
resources
:geo_nodes
,
only:
[
:index
,
:create
,
:destroy
]
resources
:geo_nodes
,
only:
[
:index
,
:create
,
:destroy
]
do
member
do
post
:repair
end
end
resources
:labels
...
...
spec/models/geo_node_spec.rb
View file @
5316aa63
...
...
@@ -4,6 +4,8 @@ describe GeoNode, type: :model do
subject
(
:new_node
)
{
described_class
.
new
(
schema:
'https'
,
host:
'localhost'
,
port:
3000
,
relative_url_root:
'gitlab'
)
}
subject
(
:new_primary_node
)
{
described_class
.
new
(
schema:
'https'
,
host:
'localhost'
,
port:
3000
,
relative_url_root:
'gitlab'
,
primary:
true
)
}
subject
(
:empty_node
)
{
described_class
.
new
(
schema:
nil
,
host:
nil
,
port:
nil
,
relative_url_root:
nil
)
}
subject
(
:primary_node
)
{
FactoryGirl
.
create
(
:geo_node
,
:primary
)
}
subject
(
:node
)
{
FactoryGirl
.
create
(
:geo_node
)
}
let
(
:dummy_url
)
{
'https://localhost:3000/gitlab'
}
...
...
@@ -62,35 +64,22 @@ describe GeoNode, type: :model do
expect
(
new_node
.
geo_node_key
).
to
be_present
end
it
'initializes a corresponding oauth application'
do
expect
(
new_node
.
oauth_application
).
to
be_present
end
it
'is valid'
do
expect
(
new_node
).
to
be_valid
end
end
context
'on create'
do
before
(
:each
)
do
new_node
.
geo_node_key_attributes
=
geo_node_key_attributes
new_primary_node
.
geo_node_key_attributes
=
geo_node_key_attributes
end
it
'saves a corresponding key'
do
new_node
.
save!
expect
(
new_node
.
geo_node_key
).
to
be_persisted
expect
(
node
.
geo_node_key
).
to
be_persisted
end
it
'saves a corresponding oauth application if it is a secondary node'
do
new_node
.
save!
expect
(
new_node
.
oauth_application
).
to
be_persisted
expect
(
node
.
oauth_application
).
to
be_persisted
end
it
'has no oauth_application if it is a primary node'
do
new_primary_node
.
save!
expect
(
new_primary_node
.
oauth_application
).
not_to
be_present
expect
(
primary_node
.
oauth_application
).
not_to
be_present
end
end
end
...
...
@@ -169,17 +158,18 @@ describe GeoNode, type: :model do
describe
'#missing_oauth_application?'
do
context
'on a primary node'
do
it
'returns false'
do
expect
(
new_
primary_node
).
not_to
be_missing_oauth_application
expect
(
primary_node
).
not_to
be_missing_oauth_application
end
end
it
'returns false when present'
do
expect
(
n
ew_n
ode
).
not_to
be_missing_oauth_application
expect
(
node
).
not_to
be_missing_oauth_application
end
it
'returns true when it is not present'
do
new_node
.
oauth_application
=
nil
expect
(
new_node
).
to
be_missing_oauth_application
node
.
oauth_application
.
destroy!
node
.
reload
expect
(
node
).
to
be_missing_oauth_application
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