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
160a6f81
Commit
160a6f81
authored
Apr 14, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove token from geo_node and some
💄
parent
a9095fcc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
21 deletions
+19
-21
app/models/geo_node.rb
app/models/geo_node.rb
+16
-11
db/migrate/20160414032323_add_token_to_geo_node.rb
db/migrate/20160414032323_add_token_to_geo_node.rb
+0
-5
db/schema.rb
db/schema.rb
+0
-1
lib/api/helpers.rb
lib/api/helpers.rb
+1
-1
spec/models/geo_node_spec.rb
spec/models/geo_node_spec.rb
+1
-2
spec/requests/api/geo_spec.rb
spec/requests/api/geo_spec.rb
+1
-1
No files found.
app/models/geo_node.rb
View file @
160a6f81
...
...
@@ -19,8 +19,7 @@ class GeoNode < ActiveRecord::Base
host:
lambda
{
Gitlab
.
config
.
gitlab
.
host
},
port:
80
,
relative_url_root:
''
,
primary:
false
,
token:
lambda
{
SecureRandom
.
hex
(
20
)
}
primary:
false
accepts_nested_attributes_for
:geo_node_key
,
:system_hook
...
...
@@ -86,23 +85,17 @@ class GeoNode < ActiveRecord::Base
def
build_dependents
self
.
build_geo_node_key
if
geo_node_key
.
nil?
update_system_hook!
end
def
update_dependents_attributes
self
.
geo_node_key
.
title
=
"Geo node:
#{
self
.
url
}
"
if
self
.
geo_node_key
self
.
token
=
SecureRandom
.
hex
(
20
)
if
!
self
.
token
.
present?
if
self
.
primary?
self
.
oauth_application
=
nil
else
# OAuth Application
self
.
build_oauth_application
if
oauth_application
.
nil?
self
.
oauth_application
.
name
=
"Geo node:
#{
self
.
url
}
"
self
.
oauth_application
.
redirect_uri
=
oauth_callback_url
# SystemHook
self
.
build_system_hook
if
system_hook
.
nil?
self
.
system_hook
.
url
=
geo_events_url
self
.
system_hook
.
token
=
token
update_oauth_application!
update_system_hook!
end
end
...
...
@@ -114,4 +107,16 @@ class GeoNode < ActiveRecord::Base
record
.
errors
[
:base
]
<<
'Current node must be the primary node or you will be locking yourself out'
end
end
def
update_oauth_application!
self
.
build_oauth_application
if
oauth_application
.
nil?
self
.
oauth_application
.
name
=
"Geo node:
#{
self
.
url
}
"
self
.
oauth_application
.
redirect_uri
=
oauth_callback_url
end
def
update_system_hook!
self
.
build_system_hook
if
system_hook
.
nil?
self
.
system_hook
.
token
=
SecureRandom
.
hex
(
20
)
unless
self
.
system_hook
.
token
.
present?
self
.
system_hook
.
url
=
geo_events_url
if
uri
.
present?
end
end
db/migrate/20160414032323_add_token_to_geo_node.rb
deleted
100644 → 0
View file @
a9095fcc
class
AddTokenToGeoNode
<
ActiveRecord
::
Migration
def
change
add_column
:geo_nodes
,
:token
,
:string
end
end
db/schema.rb
View file @
160a6f81
...
...
@@ -420,7 +420,6 @@ ActiveRecord::Schema.define(version: 20160414064845) do
t
.
boolean
"primary"
t
.
integer
"geo_node_key_id"
t
.
integer
"oauth_application_id"
t
.
string
"token"
t
.
integer
"system_hook_id"
end
...
...
lib/api/helpers.rb
View file @
160a6f81
...
...
@@ -382,7 +382,7 @@ module API
end
def
geo_token
Gitlab
::
Geo
.
current_node
.
token
Gitlab
::
Geo
.
current_node
.
system_hook
.
token
end
def
handle_member_errors
(
errors
)
...
...
spec/models/geo_node_spec.rb
View file @
160a6f81
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
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
(
:empty_node
)
{
described_class
.
new
}
subject
(
:primary_node
)
{
FactoryGirl
.
create
(
:geo_node
,
:primary
)
}
subject
(
:node
)
{
FactoryGirl
.
create
(
:geo_node
)
}
...
...
@@ -87,7 +87,6 @@ describe GeoNode, type: :model do
expect
(
node
.
system_hook
.
url
).
to
be_present
expect
(
node
.
system_hook
.
url
).
to
eq
(
node
.
geo_events_url
)
expect
(
node
.
system_hook
.
token
).
to
be_present
expect
(
node
.
system_hook
.
token
).
to
eq
(
node
.
token
)
end
end
end
...
...
spec/requests/api/geo_spec.rb
View file @
160a6f81
...
...
@@ -27,7 +27,7 @@ describe API::API, api: true do
end
let
(
:geo_token_header
)
do
{
'X-Gitlab-Token'
=>
geo_node
.
token
}
{
'X-Gitlab-Token'
=>
geo_node
.
system_hook
.
token
}
end
let
(
:key_create_payload
)
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