-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add proxy pass route for id resolution #4356
Changes from 6 commits
7d62401
2eb2a60
b3ce663
5ecf8fd
bdd1a7e
82138c2
d575bef
5053dcd
b310b48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
curl "http://localhost:8080/v1/resolve-proxy-pass/nexus/data/identifier" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
303 See Other | ||
The response to the request can be found under <a href="https://localhost:8080/v1/resolve/https:%2F%2Fexample.com%2Fnexus%2Fdata%2Fidentifier">this URI</a> using a | ||
GET method. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
303 See Other | ||
The response to the request can be found under <a href="http://localhost:8080/fusion/resolve/https:%2F%2Fexample.com%2Fnexus%2Fdata%2Fidentifier">this URI</a> using a | ||
GET method. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,11 @@ class IdResolutionSpec extends BaseSpec { | |
private val uniqueResourcePayload = resource(uniqueId) | ||
private val reusedResourcePayload = resource(reusedId) | ||
|
||
private val neurosciencegraphSegment = "neurosciencegraph/data/segment" | ||
private val proxyIdBase = "http://localhost:8081" | ||
private val neurosciencegraphId = s"$proxyIdBase/$neurosciencegraphSegment" | ||
private val encodedNeurosciencegraphId = UrlUtils.encode(neurosciencegraphId) | ||
|
||
private val unauthorizedAccessErrorPayload = | ||
jsonContentOf("iam/errors/unauthorized-access.json") | ||
|
||
|
@@ -110,6 +115,20 @@ class IdResolutionSpec extends BaseSpec { | |
|
||
"redirect to fusion resource selection page if text/html accept header is present (multiple result)" in { pending } | ||
|
||
"redirect to delta resolve if the request comes to the proxy endpoint" in { | ||
deltaClient.get[String](s"/resolve-proxy-pass/$neurosciencegraphSegment", Bob) { (_, response) => | ||
response.status shouldEqual StatusCodes.SeeOther | ||
locationHeaderOf(response) shouldEqual deltaResolveEndpoint(encodedNeurosciencegraphId) | ||
}(PredefinedFromEntityUnmarshallers.stringUnmarshaller) | ||
} | ||
|
||
"redirect to fusion resolve if the request comes to the proxy endpoint with text/html accept header is present" in { | ||
deltaClient.get[String](s"/resolve-proxy-pass/$neurosciencegraphSegment", Bob, acceptTextHtml) { (_, response) => | ||
response.status shouldEqual StatusCodes.SeeOther | ||
locationHeaderOf(response) shouldEqual fusionResolveEndpoint(encodedNeurosciencegraphId) | ||
}(PredefinedFromEntityUnmarshallers.stringUnmarshaller) | ||
} | ||
|
||
} | ||
|
||
private def locationHeaderOf(response: HttpResponse) = | ||
|
@@ -118,5 +137,9 @@ class IdResolutionSpec extends BaseSpec { | |
List(Accept(MediaRange.One(`text/html`, 1f))) | ||
private def fusionResourcePageFor(encodedId: String) = | ||
s"https://bbp.epfl.ch/nexus/web/$ref11/resources/$encodedId".replace("%3A", ":") | ||
private def fusionResolveEndpoint(encodedId: String) = | ||
s"https://bbp.epfl.ch/nexus/web/resolve/$encodedId".replace("%3A", ":") | ||
private def deltaResolveEndpoint(encodedId: String) = | ||
s"http://delta:8080/v1/resolve/$encodedId".replace("%3A", ":") | ||
Comment on lines
+143
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be URL encoded? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I follow why it should be encoded? I don't think the location in a redirect needs to be encoded? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the last segment is encoded because it needs to be a single segment representing the resource ID, and that can contain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if other unpredictable things could happen if url characters are in the ID |
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dream assertion would be
response shouldBe redirectTo(fusionResolveEndpoint(encodedNeurosciencegraphId))
It would be really nice to get rid of this boilerplate too but I don't know how:
(PredefinedFromEntityUnmarshallers.stringUnmarshaller)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but with this option we'd be matching on the response body which is not really relevant