final fixes
* fix auth test * fix notices test and parallelize * cleanup unused input lookup
This commit is contained in:
parent
09fcd573b4
commit
f96b916177
|
@ -234,27 +234,6 @@ func (h WithSSBHandler) decideMethod(w http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
// input either an alias or a feed reference
|
||||
// it is set by the landing form if non of the params are present
|
||||
if input := queryVals.Get("input"); input != "" {
|
||||
// assume ssb id first
|
||||
var err error
|
||||
cid, err = refs.ParseFeedRef(input)
|
||||
if err != nil {
|
||||
// try input as an alias
|
||||
aliasEntry, err := h.aliasesdb.Resolve(req.Context(), input)
|
||||
if err != nil {
|
||||
h.render.Error(w, req, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
cid = &aliasEntry.Feed
|
||||
alias = aliasEntry.Name
|
||||
}
|
||||
|
||||
// update cid for server-initiated
|
||||
queryVals.Set("cid", cid.Ref())
|
||||
}
|
||||
|
||||
// ?cid=CID&cc=CC does client-initiated http-auth
|
||||
if cc := queryVals.Get("cc"); cc != "" && cid != nil {
|
||||
err := h.clientInitiated(w, req, *cid)
|
||||
|
|
|
@ -50,18 +50,14 @@ func TestLoginForm(t *testing.T) {
|
|||
|
||||
a, r := assert.New(t), require.New(t)
|
||||
|
||||
ts.AliasesDB.ResolveReturns(roomdb.Alias{}, roomdb.ErrNotFound)
|
||||
|
||||
url, err := ts.Router.Get(router.AuthLogin).URL()
|
||||
url, err := ts.Router.Get(router.AuthFallbackLogin).URL()
|
||||
r.Nil(err)
|
||||
html, resp := ts.Client.GetHTML(url.String())
|
||||
a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
|
||||
|
||||
webassert.Localized(t, html, []webassert.LocalizedElement{
|
||||
{"title", "AuthTitle"},
|
||||
{"#welcome", "AuthWelcome"},
|
||||
{"#describe-withssb", "AuthWithSSBStart"},
|
||||
{"#describe-password", "AuthFallbackWelcome"},
|
||||
{"#welcome", "AuthFallbackWelcome"},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -73,9 +69,7 @@ func TestFallbackAuth(t *testing.T) {
|
|||
jar, err := cookiejar.New(nil)
|
||||
r.NoError(err)
|
||||
|
||||
ts.AliasesDB.ResolveReturns(roomdb.Alias{}, roomdb.ErrNotFound)
|
||||
|
||||
signInFormURL, err := ts.Router.Get(router.AuthLogin).URL()
|
||||
signInFormURL, err := ts.Router.Get(router.AuthFallbackLogin).URL()
|
||||
r.Nil(err)
|
||||
signInFormURL.Host = "localhost"
|
||||
signInFormURL.Scheme = "https"
|
||||
|
@ -108,7 +102,7 @@ func TestFallbackAuth(t *testing.T) {
|
|||
}
|
||||
ts.AuthFallbackDB.CheckReturns(int64(23), nil)
|
||||
|
||||
signInURL, err := ts.Router.Get(router.AuthFallbackLogin).URL()
|
||||
signInURL, err := ts.Router.Get(router.AuthFallbackFinalize).URL()
|
||||
r.Nil(err)
|
||||
|
||||
signInURL.Host = "localhost"
|
||||
|
@ -205,7 +199,7 @@ func TestAuthWithSSBClientInitNotConnected(t *testing.T) {
|
|||
|
||||
urlTo := web.NewURLTo(ts.Router)
|
||||
|
||||
signInStartURL := urlTo(router.AuthLogin,
|
||||
signInStartURL := urlTo(router.AuthWithSSBLogin,
|
||||
"cid", client.Feed.Ref(),
|
||||
"cc", cc,
|
||||
)
|
||||
|
@ -236,7 +230,7 @@ func TestAuthWithSSBClientInitNotAllowed(t *testing.T) {
|
|||
|
||||
urlTo := web.NewURLTo(ts.Router)
|
||||
|
||||
signInStartURL := urlTo(router.AuthLogin,
|
||||
signInStartURL := urlTo(router.AuthWithSSBLogin,
|
||||
"cid", client.Feed.Ref(),
|
||||
"cc", cc,
|
||||
)
|
||||
|
@ -318,7 +312,7 @@ func TestAuthWithSSBClientInitHasClient(t *testing.T) {
|
|||
|
||||
// prepare the url
|
||||
urlTo := web.NewURLTo(ts.Router)
|
||||
signInStartURL := urlTo(router.AuthLogin,
|
||||
signInStartURL := urlTo(router.AuthWithSSBLogin,
|
||||
"cid", client.Feed.Ref(),
|
||||
"cc", cc,
|
||||
)
|
||||
|
@ -401,7 +395,7 @@ func TestAuthWithSSBServerInitHappyPath(t *testing.T) {
|
|||
|
||||
// prepare the url
|
||||
urlTo := web.NewURLTo(ts.Router)
|
||||
signInStartURL := urlTo(router.AuthLogin,
|
||||
signInStartURL := urlTo(router.AuthWithSSBLogin,
|
||||
"cid", client.Feed.Ref(),
|
||||
)
|
||||
r.NotNil(signInStartURL)
|
||||
|
@ -413,7 +407,7 @@ func TestAuthWithSSBServerInitHappyPath(t *testing.T) {
|
|||
|
||||
webassert.Localized(t, html, []webassert.LocalizedElement{
|
||||
{"title", "AuthWithSSBTitle"},
|
||||
{"#welcome", "AuthWithSSBServerStart"},
|
||||
{"#welcome", "AuthWithSSBWelcome"},
|
||||
})
|
||||
|
||||
jsFile, has := html.Find("script").Attr("src")
|
||||
|
@ -527,7 +521,7 @@ func TestAuthWithSSBServerInitWrongSolution(t *testing.T) {
|
|||
|
||||
// prepare the url
|
||||
urlTo := web.NewURLTo(ts.Router)
|
||||
signInStartURL := urlTo(router.AuthLogin,
|
||||
signInStartURL := urlTo(router.AuthWithSSBLogin,
|
||||
"cid", client.Feed.Ref(),
|
||||
)
|
||||
r.NotNil(signInStartURL)
|
||||
|
|
|
@ -91,7 +91,7 @@ func TestNoticesEditButtonVisible(t *testing.T) {
|
|||
|
||||
// when dealing with cookies we also need to have an Host and URL-Scheme
|
||||
// for the jar to save and load them correctly
|
||||
formEndpoint := urlTo(router.AuthLogin)
|
||||
formEndpoint := urlTo(router.AuthFallbackLogin)
|
||||
r.NotNil(formEndpoint)
|
||||
formEndpoint.Host = "localhost"
|
||||
formEndpoint.Scheme = "https"
|
||||
|
@ -128,7 +128,7 @@ func TestNoticesEditButtonVisible(t *testing.T) {
|
|||
ts.AuthFallbackDB.CheckReturns(testUser.ID, nil)
|
||||
ts.MembersDB.GetByIDReturns(testUser, nil)
|
||||
|
||||
postEndpoint, err := ts.Router.Get(router.AuthFallbackLogin).URL()
|
||||
postEndpoint, err := ts.Router.Get(router.AuthFallbackFinalize).URL()
|
||||
r.Nil(err)
|
||||
postEndpoint.Host = "localhost"
|
||||
postEndpoint.Scheme = "https"
|
||||
|
|
|
@ -55,6 +55,7 @@ type testSession struct {
|
|||
var testI18N = justTheKeys()
|
||||
|
||||
func setup(t *testing.T) *testSession {
|
||||
t.Parallel()
|
||||
var ts testSession
|
||||
|
||||
testRepoPath := filepath.Join("testrun", t.Name())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{ define "title" }}{{i18n "AuthTitle"}}{{ end }}
|
||||
{{ define "content" }}
|
||||
<div class="flex flex-col justify-center items-center self-center max-w-lg">
|
||||
<span class="text-center mt-8">{{i18n "AuthFallbackWelcome"}}</span>
|
||||
<span id="welcome" class="text-center mt-8">{{i18n "AuthFallbackWelcome"}}</span>
|
||||
|
||||
<form
|
||||
id="password-fallback"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{ define "title" }}{{i18n "AuthWithSSBTitle"}}{{ end }}
|
||||
{{ define "content" }}
|
||||
<div class="flex flex-col justify-center items-center self-center max-w-lg">
|
||||
<span class="text-center mt-8">{{i18n "AuthWithSSBWelcome"}}</span>
|
||||
<span id="welcome" class="text-center mt-8">{{i18n "AuthWithSSBWelcome"}}</span>
|
||||
|
||||
<a
|
||||
id="start-auth-uri"
|
||||
|
|
Loading…
Reference in New Issue