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
72181996
Commit
72181996
authored
Sep 24, 2020
by
Tim Rizzi
Committed by
James Lopez
Sep 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add npm request forwarding to snowplow
parent
67f1e148
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
1 deletion
+13
-1
changelogs/unreleased/40174-snowflake-npm-forward.yml
changelogs/unreleased/40174-snowflake-npm-forward.yml
+5
-0
lib/api/helpers/packages/dependency_proxy_helpers.rb
lib/api/helpers/packages/dependency_proxy_helpers.rb
+1
-0
spec/lib/api/helpers/packages/dependency_proxy_helpers_spec.rb
...lib/api/helpers/packages/dependency_proxy_helpers_spec.rb
+2
-0
spec/requests/api/npm_packages_spec.rb
spec/requests/api/npm_packages_spec.rb
+5
-1
No files found.
changelogs/unreleased/40174-snowflake-npm-forward.yml
0 → 100644
View file @
72181996
---
title
:
Measure npm request forwarding usage
merge_request
:
40174
author
:
type
:
added
lib/api/helpers/packages/dependency_proxy_helpers.rb
View file @
72181996
...
...
@@ -10,6 +10,7 @@ module API
def
redirect_registry_request
(
forward_to_registry
,
package_type
,
options
)
if
forward_to_registry
&&
redirect_registry_request_available?
track_event
(
"
#{
package_type
}
_request_forward"
)
redirect
(
registry_url
(
package_type
,
options
))
else
yield
...
...
spec/lib/api/helpers/packages/dependency_proxy_helpers_spec.rb
View file @
72181996
...
...
@@ -24,6 +24,7 @@ RSpec.describe API::Helpers::Packages::DependencyProxyHelpers do
shared_examples
'executing redirect'
do
it
'redirects to package registry'
do
expect
(
helper
).
to
receive
(
:track_event
).
with
(
'npm_request_forward'
).
once
expect
(
helper
).
to
receive
(
:registry_url
).
once
expect
(
helper
).
to
receive
(
:redirect
).
once
expect
(
helper
).
to
receive
(
:fallback
).
never
...
...
@@ -63,6 +64,7 @@ RSpec.describe API::Helpers::Packages::DependencyProxyHelpers do
let
(
:package_type
)
{
pkg_type
}
it
'raises an error'
do
allow
(
helper
).
to
receive
(
:track_event
)
expect
{
subject
}.
to
raise_error
(
ArgumentError
,
"Can't build registry_url for package_type
#{
package_type
}
"
)
end
end
...
...
spec/requests/api/npm_packages_spec.rb
View file @
72181996
...
...
@@ -88,12 +88,16 @@ RSpec.describe API::NpmPackages do
it_behaves_like
'returning the npm package info'
context
'with unknown package'
do
subject
{
get
api
(
"/packages/npm/unknown"
)
}
it
'returns a redirect'
do
get
api
(
"/packages/npm/unknown"
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
expect
(
response
.
headers
[
'Location'
]).
to
eq
(
'https://registry.npmjs.org/unknown'
)
end
it_behaves_like
'a gitlab tracking event'
,
described_class
.
name
,
'npm_request_forward'
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