mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 01:38:50 +02:00
fix(test): update test expectations
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
"github.com/yusing/godoxy/internal/common"
|
"github.com/yusing/godoxy/internal/common"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
|
"golang.org/x/time/rate"
|
||||||
|
|
||||||
expect "github.com/yusing/goutils/testing"
|
expect "github.com/yusing/goutils/testing"
|
||||||
)
|
)
|
||||||
@@ -42,6 +43,7 @@ func setupMockOIDC(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
allowedUsers: []string{"test-user"},
|
allowedUsers: []string{"test-user"},
|
||||||
allowedGroups: []string{"test-group1", "test-group2"},
|
allowedGroups: []string{"test-group1", "test-group2"},
|
||||||
|
rateLimit: rate.NewLimiter(rate.Every(common.OIDCRateLimitPeriod), common.OIDCRateLimit),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ func TestReverseProxyBypass(t *testing.T) {
|
|||||||
rp := reverseproxy.NewReverseProxy("test", url, fakeRoundTripper{})
|
rp := reverseproxy.NewReverseProxy("test", url, fakeRoundTripper{})
|
||||||
err = PatchReverseProxy(rp, map[string]OptionsRaw{
|
err = PatchReverseProxy(rp, map[string]OptionsRaw{
|
||||||
"response": {
|
"response": {
|
||||||
"bypass": "path glob(/test/*) | path /api",
|
"bypass": []string{"path glob(/test/*)", "path /api"},
|
||||||
"set_headers": map[string]string{
|
"set_headers": map[string]string{
|
||||||
"Test-Header": "test-value",
|
"Test-Header": "test-value",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -788,6 +788,15 @@ func (r *Route) Finalize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.Port.Listening, r.Port.Proxy = lp, pp
|
r.Port.Listening, r.Port.Proxy = lp, pp
|
||||||
|
|
||||||
|
workingState := config.WorkingState.Load()
|
||||||
|
if workingState == nil {
|
||||||
|
if common.IsTest { // in tests, working state might be nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
panic("bug: working state is nil")
|
||||||
|
}
|
||||||
|
|
||||||
r.HealthCheck.ApplyDefaults(config.WorkingState.Load().Value().Defaults.HealthCheck)
|
r.HealthCheck.ApplyDefaults(config.WorkingState.Load().Value().Defaults.HealthCheck)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ func TestLogCommand_ConditionalLogging(t *testing.T) {
|
|||||||
errorContent, err := os.ReadFile(errorFile.Name())
|
errorContent, err := os.ReadFile(errorFile.Name())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
errorLines := strings.Split(strings.TrimSpace(string(errorContent)), "\n")
|
errorLines := strings.Split(strings.TrimSpace(string(errorContent)), "\n")
|
||||||
assert.Len(t, errorLines, 2)
|
require.Len(t, errorLines, 2)
|
||||||
assert.Equal(t, "ERROR: GET /notfound 404", errorLines[0])
|
assert.Equal(t, "ERROR: GET /notfound 404", errorLines[0])
|
||||||
assert.Equal(t, "ERROR: POST /error 500", errorLines[1])
|
assert.Equal(t, "ERROR: POST /error 500", errorLines[1])
|
||||||
}
|
}
|
||||||
@@ -368,7 +368,7 @@ func TestLogCommand_FilePermissions(t *testing.T) {
|
|||||||
logContent := strings.TrimSpace(string(content))
|
logContent := strings.TrimSpace(string(content))
|
||||||
lines := strings.Split(logContent, "\n")
|
lines := strings.Split(logContent, "\n")
|
||||||
|
|
||||||
assert.Len(t, lines, 2)
|
require.Len(t, lines, 2)
|
||||||
assert.Equal(t, "GET 200", lines[0])
|
assert.Equal(t, "GET 200", lines[0])
|
||||||
assert.Equal(t, "POST 200", lines[1])
|
assert.Equal(t, "POST 200", lines[1])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -27,7 +26,7 @@ test:
|
|||||||
ca_file: /etc/ssl/ca.crt
|
ca_file: /etc/ssl/ca.crt
|
||||||
cert_file: /etc/ssl/cert.crt
|
cert_file: /etc/ssl/cert.crt
|
||||||
key_file: /etc/ssl/key.crt`), &cfg)
|
key_file: /etc/ssl/key.crt`), &cfg)
|
||||||
assert.Error(t, err, os.ErrNotExist)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, &DockerProviderConfig{URL: "http://localhost:2375", TLS: &DockerTLSConfig{CAFile: "/etc/ssl/ca.crt", CertFile: "/etc/ssl/cert.crt", KeyFile: "/etc/ssl/key.crt"}}, cfg["test"])
|
assert.Equal(t, &DockerProviderConfig{URL: "http://localhost:2375", TLS: &DockerTLSConfig{CAFile: "/etc/ssl/ca.crt", CertFile: "/etc/ssl/cert.crt", KeyFile: "/etc/ssl/key.crt"}}, cfg["test"])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user