|
@@ -6,6 +6,7 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/http"
|
|
|
|
+ "net/url"
|
|
"os"
|
|
"os"
|
|
"strings"
|
|
"strings"
|
|
"testing"
|
|
"testing"
|
|
@@ -82,7 +83,7 @@ query: >
|
|
config: `
|
|
config: `
|
|
mode: tail
|
|
mode: tail
|
|
source: loki
|
|
source: loki
|
|
-url: http://@localhost:3100/
|
|
|
|
|
|
+url: http://localhost:3100/
|
|
auth:
|
|
auth:
|
|
username: foo
|
|
username: foo
|
|
password: bar
|
|
password: bar
|
|
@@ -125,6 +126,7 @@ func TestConfigureDSN(t *testing.T) {
|
|
expectedErr string
|
|
expectedErr string
|
|
since time.Time
|
|
since time.Time
|
|
password string
|
|
password string
|
|
|
|
+ scheme string
|
|
waitForReady time.Duration
|
|
waitForReady time.Duration
|
|
}{
|
|
}{
|
|
{
|
|
{
|
|
@@ -163,6 +165,11 @@ func TestConfigureDSN(t *testing.T) {
|
|
expectedErr: "",
|
|
expectedErr: "",
|
|
waitForReady: 5 * time.Second,
|
|
waitForReady: 5 * time.Second,
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ name: "SSL DSN",
|
|
|
|
+ dsn: `loki://localhost:3100/?ssl=true`,
|
|
|
|
+ scheme: "https",
|
|
|
|
+ },
|
|
}
|
|
}
|
|
|
|
|
|
for _, test := range tests {
|
|
for _, test := range tests {
|
|
@@ -186,6 +193,12 @@ func TestConfigureDSN(t *testing.T) {
|
|
t.Fatalf("Password mismatch : %s != %s", test.password, p)
|
|
t.Fatalf("Password mismatch : %s != %s", test.password, p)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if test.scheme != "" {
|
|
|
|
+ url, _ := url.Parse(lokiSource.Config.URL)
|
|
|
|
+ if test.scheme != url.Scheme {
|
|
|
|
+ t.Fatalf("Schema mismatch : %s != %s", test.scheme, url.Scheme)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if test.waitForReady != 0 {
|
|
if test.waitForReady != 0 {
|
|
if lokiSource.Config.WaitForReady != test.waitForReady {
|
|
if lokiSource.Config.WaitForReady != test.waitForReady {
|
|
t.Fatalf("Wrong WaitForReady %v != %v", lokiSource.Config.WaitForReady, test.waitForReady)
|
|
t.Fatalf("Wrong WaitForReady %v != %v", lokiSource.Config.WaitForReady, test.waitForReady)
|