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
d78dfe21
Commit
d78dfe21
authored
Jul 08, 2020
by
Giorgenes Gelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move PackagesManagerApiSpecHelpers to core
move dependency api helpers for the upcoming move of packages to core.
parent
9752dac7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
56 deletions
+54
-56
ee/spec/requests/api/composer_packages_spec.rb
ee/spec/requests/api/composer_packages_spec.rb
+1
-1
ee/spec/requests/api/conan_packages_spec.rb
ee/spec/requests/api/conan_packages_spec.rb
+1
-1
ee/spec/requests/api/go_proxy_spec.rb
ee/spec/requests/api/go_proxy_spec.rb
+1
-1
ee/spec/requests/api/npm_packages_spec.rb
ee/spec/requests/api/npm_packages_spec.rb
+1
-1
ee/spec/requests/api/nuget_packages_spec.rb
ee/spec/requests/api/nuget_packages_spec.rb
+1
-1
ee/spec/requests/api/pypi_packages_spec.rb
ee/spec/requests/api/pypi_packages_spec.rb
+1
-1
ee/spec/services/packages/composer/create_package_service_spec.rb
...services/packages/composer/create_package_service_spec.rb
+1
-1
ee/spec/services/packages/pypi/create_package_service_spec.rb
...pec/services/packages/pypi/create_package_service_spec.rb
+1
-1
ee/spec/support/helpers/ee/packages_manager_api_spec_helper.rb
...ec/support/helpers/ee/packages_manager_api_spec_helper.rb
+0
-48
spec/support/helpers/packages_manager_api_spec_helper.rb
spec/support/helpers/packages_manager_api_spec_helper.rb
+46
-0
No files found.
ee/spec/requests/api/composer_packages_spec.rb
View file @
d78dfe21
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
API
::
ComposerPackages
do
RSpec
.
describe
API
::
ComposerPackages
do
include
EE
::
PackagesManagerApiSpecHelpers
include
PackagesManagerApiSpecHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
,
reload:
true
)
{
create
(
:group
,
:public
)
}
let_it_be
(
:group
,
reload:
true
)
{
create
(
:group
,
:public
)
}
...
...
ee/spec/requests/api/conan_packages_spec.rb
View file @
d78dfe21
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
RSpec
.
describe
API
::
ConanPackages
do
RSpec
.
describe
API
::
ConanPackages
do
include
WorkhorseHelpers
include
WorkhorseHelpers
include
EE
::
PackagesManagerApiSpecHelpers
include
PackagesManagerApiSpecHelpers
let
(
:package
)
{
create
(
:conan_package
)
}
let
(
:package
)
{
create
(
:conan_package
)
}
let_it_be
(
:personal_access_token
)
{
create
(
:personal_access_token
)
}
let_it_be
(
:personal_access_token
)
{
create
(
:personal_access_token
)
}
...
...
ee/spec/requests/api/go_proxy_spec.rb
View file @
d78dfe21
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
API
::
GoProxy
do
RSpec
.
describe
API
::
GoProxy
do
include
EE
::
PackagesManagerApiSpecHelpers
include
PackagesManagerApiSpecHelpers
let_it_be
(
:user
)
{
create
:user
}
let_it_be
(
:user
)
{
create
:user
}
let_it_be
(
:project
)
{
create
:project_empty_repo
,
creator:
user
,
path:
'my-go-lib'
}
let_it_be
(
:project
)
{
create
:project_empty_repo
,
creator:
user
,
path:
'my-go-lib'
}
...
...
ee/spec/requests/api/npm_packages_spec.rb
View file @
d78dfe21
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
API
::
NpmPackages
do
RSpec
.
describe
API
::
NpmPackages
do
include
EE
::
PackagesManagerApiSpecHelpers
include
PackagesManagerApiSpecHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
...
...
ee/spec/requests/api/nuget_packages_spec.rb
View file @
d78dfe21
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
RSpec
.
describe
API
::
NugetPackages
do
RSpec
.
describe
API
::
NugetPackages
do
include
WorkhorseHelpers
include
WorkhorseHelpers
include
EE
::
PackagesManagerApiSpecHelpers
include
PackagesManagerApiSpecHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
,
:public
)
}
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
,
:public
)
}
...
...
ee/spec/requests/api/pypi_packages_spec.rb
View file @
d78dfe21
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
RSpec
.
describe
API
::
PypiPackages
do
RSpec
.
describe
API
::
PypiPackages
do
include
WorkhorseHelpers
include
WorkhorseHelpers
include
EE
::
PackagesManagerApiSpecHelpers
include
PackagesManagerApiSpecHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
,
:public
)
}
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
,
:public
)
}
...
...
ee/spec/services/packages/composer/create_package_service_spec.rb
View file @
d78dfe21
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Packages
::
Composer
::
CreatePackageService
do
RSpec
.
describe
Packages
::
Composer
::
CreatePackageService
do
include
EE
::
PackagesManagerApiSpecHelpers
include
PackagesManagerApiSpecHelpers
let_it_be
(
:package_name
)
{
'composer-package-name'
}
let_it_be
(
:package_name
)
{
'composer-package-name'
}
let_it_be
(
:json
)
{
{
name:
package_name
}.
to_json
}
let_it_be
(
:json
)
{
{
name:
package_name
}.
to_json
}
...
...
ee/spec/services/packages/pypi/create_package_service_spec.rb
View file @
d78dfe21
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Packages
::
Pypi
::
CreatePackageService
do
RSpec
.
describe
Packages
::
Pypi
::
CreatePackageService
do
include
EE
::
PackagesManagerApiSpecHelpers
include
PackagesManagerApiSpecHelpers
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
...
...
ee/spec/support/helpers/ee/packages_manager_api_spec_helper.rb
deleted
100644 → 0
View file @
9752dac7
# frozen_string_literal: true
module
EE
module
PackagesManagerApiSpecHelpers
def
build_auth_headers
(
value
)
{
'HTTP_AUTHORIZATION'
=>
value
}
end
def
build_basic_auth_header
(
username
,
password
)
build_auth_headers
(
ActionController
::
HttpAuthentication
::
Basic
.
encode_credentials
(
username
,
password
))
end
def
build_token_auth_header
(
token
)
build_auth_headers
(
"Bearer
#{
token
}
"
)
end
def
build_jwt
(
personal_access_token
,
secret:
jwt_secret
,
user_id:
nil
)
JSONWebToken
::
HMACToken
.
new
(
secret
).
tap
do
|
jwt
|
jwt
[
'access_token'
]
=
personal_access_token
.
id
jwt
[
'user_id'
]
=
user_id
||
personal_access_token
.
user_id
end
end
def
build_jwt_from_job
(
job
,
secret:
jwt_secret
)
JSONWebToken
::
HMACToken
.
new
(
secret
).
tap
do
|
jwt
|
jwt
[
'access_token'
]
=
job
.
token
jwt
[
'user_id'
]
=
job
.
user
.
id
end
end
def
build_jwt_from_deploy_token
(
deploy_token
,
secret:
jwt_secret
)
JSONWebToken
::
HMACToken
.
new
(
secret
).
tap
do
|
jwt
|
jwt
[
'access_token'
]
=
deploy_token
.
token
jwt
[
'user_id'
]
=
deploy_token
.
username
end
end
def
temp_file
(
package_tmp
)
upload_path
=
::
Packages
::
PackageFileUploader
.
workhorse_local_upload_path
file_path
=
"
#{
upload_path
}
/
#{
package_tmp
}
"
FileUtils
.
mkdir_p
(
upload_path
)
File
.
write
(
file_path
,
'test'
)
UploadedFile
.
new
(
file_path
,
filename:
File
.
basename
(
file_path
))
end
end
end
spec/support/helpers/packages_manager_api_spec_helper.rb
0 → 100644
View file @
d78dfe21
# frozen_string_literal: true
module
PackagesManagerApiSpecHelpers
def
build_auth_headers
(
value
)
{
'HTTP_AUTHORIZATION'
=>
value
}
end
def
build_basic_auth_header
(
username
,
password
)
build_auth_headers
(
ActionController
::
HttpAuthentication
::
Basic
.
encode_credentials
(
username
,
password
))
end
def
build_token_auth_header
(
token
)
build_auth_headers
(
"Bearer
#{
token
}
"
)
end
def
build_jwt
(
personal_access_token
,
secret:
jwt_secret
,
user_id:
nil
)
JSONWebToken
::
HMACToken
.
new
(
secret
).
tap
do
|
jwt
|
jwt
[
'access_token'
]
=
personal_access_token
.
id
jwt
[
'user_id'
]
=
user_id
||
personal_access_token
.
user_id
end
end
def
build_jwt_from_job
(
job
,
secret:
jwt_secret
)
JSONWebToken
::
HMACToken
.
new
(
secret
).
tap
do
|
jwt
|
jwt
[
'access_token'
]
=
job
.
token
jwt
[
'user_id'
]
=
job
.
user
.
id
end
end
def
build_jwt_from_deploy_token
(
deploy_token
,
secret:
jwt_secret
)
JSONWebToken
::
HMACToken
.
new
(
secret
).
tap
do
|
jwt
|
jwt
[
'access_token'
]
=
deploy_token
.
token
jwt
[
'user_id'
]
=
deploy_token
.
username
end
end
def
temp_file
(
package_tmp
)
upload_path
=
::
Packages
::
PackageFileUploader
.
workhorse_local_upload_path
file_path
=
"
#{
upload_path
}
/
#{
package_tmp
}
"
FileUtils
.
mkdir_p
(
upload_path
)
File
.
write
(
file_path
,
'test'
)
UploadedFile
.
new
(
file_path
,
filename:
File
.
basename
(
file_path
))
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