mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-03 04:16:03 +02:00
authenticate: unmarshal and verify state from jwt, instead of middleware authorize: embed opa policy using statik authorize: have IsAuthorized handle authorization for all routes authorize: if no signing key is provided, one is generated authorize: remove IsAdmin grpc endpoint authorize/client: return authorize decision struct cmd/pomerium: main logger no longer contains email and group cryptutil: add ECDSA signing methods dashboard: have impersonate form show up for all users, but have api gated by authz docs: fix typo in signed jwt header encoding/jws: remove unused es256 signer frontend: namespace static web assets internal/sessions: remove leeway to match authz policy proxy: move signing functionality to authz proxy: remove jwt attestation from proxy (authZ does now) proxy: remove non-signed headers from headers proxy: remove special handling of x-forwarded-host sessions: do not verify state in middleware sessions: remove leeway from state to match authz sessions/{all}: store jwt directly instead of state Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package mock // import "github.com/pomerium/pomerium/internal/sessions/mock"
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
"github.com/pomerium/pomerium/internal/sessions"
|
|
)
|
|
|
|
func TestStore(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
store *Store
|
|
wantLoad string
|
|
saveSession *sessions.State
|
|
wantLoadErr bool
|
|
wantSaveErr bool
|
|
}{
|
|
{"basic",
|
|
&Store{
|
|
ResponseSession: "test",
|
|
Session: &sessions.State{Subject: "0101"},
|
|
SaveError: nil,
|
|
LoadError: nil,
|
|
},
|
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6IiIsInByb2dyYW1hdGljIjpmYWxzZSwic3ViIjoiMDEwMSJ9.u0dzrEkbt-Bec7Rq85E8pbglE61D7UqGN33MFtfoCCM",
|
|
&sessions.State{Subject: "0101"},
|
|
false,
|
|
false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
ms := tt.store
|
|
|
|
err := ms.SaveSession(nil, nil, tt.saveSession)
|
|
if (err != nil) != tt.wantSaveErr {
|
|
t.Errorf("mockstore.SaveSession() error = %v, wantSaveErr %v", err, tt.wantSaveErr)
|
|
return
|
|
}
|
|
got, err := ms.LoadSession(nil)
|
|
if (err != nil) != tt.wantLoadErr {
|
|
t.Errorf("mockstore.LoadSession() error = %v, wantLoadErr %v", err, tt.wantLoadErr)
|
|
return
|
|
}
|
|
if diff := cmp.Diff(got, tt.wantLoad); diff != "" {
|
|
t.Errorf("mockstore.LoadSession() = %v", diff)
|
|
}
|
|
ms.ClearSession(nil, nil)
|
|
if ms.ResponseSession != "" {
|
|
t.Errorf("ResponseSession not empty! %s", ms.ResponseSession)
|
|
}
|
|
})
|
|
}
|
|
}
|