-
Notifications
You must be signed in to change notification settings - Fork 48
Allow server URLs with custom paths or no trailing slash. #343
Conversation
When looking at adding tests, I was going back and forth between either adding three tests (one for each controller/service), which would also require me to figure out how to test successful graph/pie/metric-name loads, or extracting the URL concatentation code into a separate service and testing that once. Both seemed like a lot of overhead for such a simple orthogonal change though. Let me know if you think otherwise... |
It must not be hard to add tests or feel like it's an overhead. That means I vote to extract all the HTTP request handling here and have a common On Sat, Feb 14, 2015 at 12:41 PM, juliusv [email protected] wrote:
|
Agreed, together with the authentication header change for #341 it would make much more sense to split this out into a separate HTTP service, and then test that. I'm currently struggling to get the combination of Angular/CORS/Basic Auth working... it's a pain. The headers are just not set, etc. |
(oh yeah, and with nginx as the basic auth proxy in the middle) |
I'll add on to what @grobie said: it being hard to write a test is usually indicative of writing our code incorrectly. obviously we don't have enough hours in the day to fix everything, but I do intend on spending more time on the test suite. also, i'll review this tomorrow :P |
@juliusv added tests |
Oh, thanks so much! :) Adding some tiny comments now... |
Actually, just 👍 Once we do end up adding basic auth, we probably want to not only extract the URL building, but the whole HTTP call. But we can leave that for then. |
Allow server URLs with custom paths or no trailing slash.
it('allows urls with custom paths, no trailing slash', function() { | ||
['http://promdash.server.com/prometheus', 'http://promdash.com'].forEach(function(s) { | ||
['/api/query_range', '/api/query', '/api/metrics', '/arbitrary/endpoint'].forEach(function(ep) { | ||
var s = 'http://promdash.server.com/prometheus'; |
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.
I'm confused. First you have a s
variable which can contain two different domain names, but then you override s
to this server name only? Or what am I missing here?
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.
Oh, good catch. Yeah, looks like this line (and the same one in the test below) should be deleted?
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.
ahhh this is true. when I expanded the test to have the two different server names, i forgot to delete the original s
var.
This enables people to use PromDash behind a proxy with a custom path,
like
http://myproxy/prometheus
.