Skip to content

Commit

Permalink
test fixes, UI setup improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wardviaene committed Sep 5, 2024
1 parent 1245673 commit 6cef7e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
10 changes: 10 additions & 0 deletions pkg/auth/provisioning/scim/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ func TestCreateUserConnectionDeleteUserFlow(t *testing.T) {
w.Write([]byte("OK"))
return
}
if r.RequestURI == "/refresh-server-config" {
w.WriteHeader(http.StatusAccepted)
w.Write([]byte("OK"))
return
}
w.WriteHeader(http.StatusBadRequest)
default:
w.WriteHeader(http.StatusBadRequest)
Expand Down Expand Up @@ -348,6 +353,11 @@ func TestCreateUserConnectionSuspendUserFlow(t *testing.T) {
w.Write([]byte("OK"))
return
}
if r.RequestURI == "/refresh-server-config" {
w.WriteHeader(http.StatusAccepted)
w.Write([]byte("OK"))
return
}
w.WriteHeader(http.StatusBadRequest)
default:
w.WriteHeader(http.StatusBadRequest)
Expand Down
12 changes: 11 additions & 1 deletion pkg/rest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ func (c *Context) vpnSetupHandler(w http.ResponseWriter, r *http.Request) {
}
switch r.Method {
case http.MethodGet:
packetLogTypes := []string{}
for k, enabled := range vpnConfig.PacketLogsTypes {
if enabled {
packetLogTypes = append(packetLogTypes, k)
}
}
setupRequest := VPNSetupRequest{
Routes: strings.Join(vpnConfig.ClientRoutes, ", "),
VPNEndpoint: vpnConfig.Endpoint,
Expand All @@ -178,6 +184,8 @@ func (c *Context) vpnSetupHandler(w http.ResponseWriter, r *http.Request) {
ExternalInterface: vpnConfig.ExternalInterface,
Nameservers: strings.Join(vpnConfig.Nameservers, ","),
DisableNAT: vpnConfig.DisableNAT,
EnablePacketLogs: vpnConfig.EnablePacketLogs,
PacketLogsTypes: packetLogTypes,
}
out, err := json.Marshal(setupRequest)
if err != nil {
Expand Down Expand Up @@ -276,7 +284,9 @@ func (c *Context) vpnSetupHandler(w http.ResponseWriter, r *http.Request) {
if !slices.Equal(setupRequest.PacketLogsTypes, packetLogTypes) {
vpnConfig.PacketLogsTypes = make(map[string]bool)
for _, v := range setupRequest.PacketLogsTypes {
vpnConfig.PacketLogsTypes[v] = true
if v == "http+https" || v == "dns" || v == "tcp" {
vpnConfig.PacketLogsTypes[v] = true
}
}
writeVPNConfig = true
}
Expand Down
14 changes: 10 additions & 4 deletions webapp/src/Routes/Setup/VPNSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type VPNSetupRequest = {
nameservers: string,
disableNAT: boolean,
enablePacketLogs: boolean,
packetLogTypes: string[],
packetLogsTypes: string[],
};
export function VPNSetup() {
const [saved, setSaved] = useState(false)
Expand Down Expand Up @@ -57,7 +57,7 @@ export function VPNSetup() {
nameservers: "",
disableNAT: false,
enablePacketLogs: false,
packetLogTypes: []
packetLogsTypes: []
},
});
const setupMutation = useMutation({
Expand Down Expand Up @@ -250,8 +250,14 @@ export function VPNSetup() {
>
<MultiSelect
searchable
data={["DNS", "HTTP/HTTPS", "New TCP Connections (SYN)"]}
{...form.getInputProps('packetLogTypes')}
hidePickedOptions
comboboxProps={{ offset: 0 }}
data={[
{ value: 'dns', label: 'DNS' },
{ value: 'http+https', label: 'HTTP/HTTPS' },
{ value: 'tcp', label: 'New TCP Connections (SYN)' },
]}
{...form.getInputProps('packetLogsTypes')}
/>
</InputWrapper>
: null}
Expand Down

0 comments on commit 6cef7e8

Please sign in to comment.