mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-31 15:29:48 +02:00
## Summary Currently you can either run a single service or all-in-one mode. This PR adds support for running any 2 or 3 services together. For example `services: authorize,proxy`. I think I updated the conditions to make sense, but there's some risk here as there may have been some assumptions in places I'm overlooking. ## Related issues - [ENG-2485](https://linear.app/pomerium/issue/ENG-2485/core-support-running-multiple-but-not-all-services) ## Checklist - [x] reference any related issues - [x] updated unit tests - [x] add appropriate label (`enhancement`, `bug`, `breaking`, `dependencies`, `ci`) - [x] ready for review
134 lines
2.9 KiB
Go
134 lines
2.9 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func Test_isValidService(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
service string
|
|
want bool
|
|
}{
|
|
{"proxy", "proxy", true},
|
|
{"all", "all", true},
|
|
{"authenticate", "authenticate", true},
|
|
{"authorize implemented", "authorize", true},
|
|
{"jiberish", "xd23", false},
|
|
{"databroker", "databroker", true},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := IsValidService(tt.service); got != tt.want {
|
|
t.Errorf("isValidService() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_isAuthenticate(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
service string
|
|
want bool
|
|
}{
|
|
{"proxy", "proxy", false},
|
|
{"all", "all", true},
|
|
{"authenticate", "authenticate", true},
|
|
{"authorize implemented", "authorize", false},
|
|
{"jiberish", "xd23", false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := IsAuthenticate(tt.service); got != tt.want {
|
|
t.Errorf("isAuthenticate() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_isAuthorize(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
service string
|
|
want bool
|
|
}{
|
|
{"proxy", "proxy", false},
|
|
{"all", "all", true},
|
|
{"authorize", "authorize", true},
|
|
{"authenticate implemented", "authenticate", false},
|
|
{"jiberish", "xd23", false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := IsAuthorize(tt.service); got != tt.want {
|
|
t.Errorf("isAuthenticate() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_IsProxy(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
service string
|
|
want bool
|
|
}{
|
|
{"proxy", "proxy", true},
|
|
{"all", "all", true},
|
|
{"authorize", "authorize", false},
|
|
{"jiberish", "xd23", false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := IsProxy(tt.service); got != tt.want {
|
|
t.Errorf("IsProxy() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_IsDataBroker(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
service string
|
|
want bool
|
|
}{
|
|
{"proxy", "proxy", false},
|
|
{"all", "all", true},
|
|
{"authorize", "authorize", false},
|
|
{"jiberish", "xd23", false},
|
|
{"cache", "cache", true},
|
|
{"databroker", "databroker", true},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := IsDataBroker(tt.service); got != tt.want {
|
|
t.Errorf("IsDataBroker() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_IsAll(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
service string
|
|
want bool
|
|
}{
|
|
{"proxy", "proxy", false},
|
|
{"all", "all", true},
|
|
{"separate", "authenticate,authorize,databroker,proxy", true},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := IsDataBroker(tt.service); got != tt.want {
|
|
t.Errorf("IsAll() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|