Skip to content

Commit a00043e

Browse files
authored
Merge branch 'main' into master
2 parents 5a397d8 + 319067e commit a00043e

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ services:
2222
environment:
2323
- KC_BOOTSTRAP_ADMIN_USERNAME=keycloak
2424
- KC_BOOTSTRAP_ADMIN_PASSWORD=password
25-
- KC_LOG_LEVEL=INFO
25+
- KC_LOG_LEVEL=INFO,org.keycloak:debug
2626
- KC_DB=postgres
2727
- KC_DB_URL_HOST=postgres
2828
- KC_DB_URL_PORT=5432
2929
- KC_DB_URL_DATABASE=keycloak
3030
- KC_DB_USERNAME=keycloak
3131
- KC_DB_PASSWORD=password
32-
- KC_LOG_LEVEL=INFO
3332
- KC_LOG_CONSOLE_COLOR=true
3433
- KC_FEATURES=preview
3534
- QUARKUS_HTTP_ACCESS_LOG_ENABLED=true

keycloak/types/keycloak_slice_hash_delimited.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ type KeycloakSliceHashDelimited []string
1212
func (s KeycloakSliceHashDelimited) MarshalJSON() ([]byte, error) {
1313
var buf bytes.Buffer
1414
if s == nil || len(s) == 0 {
15-
buf.WriteString(`""`)
15+
// Allows omitempty to work
16+
return []byte("null"), nil
1617
} else {
1718
buf.WriteString(`"`)
1819

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package types
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
func TestKeycloakSliceHashDelimited_MarshalJSON(t *testing.T) {
9+
tests := []struct {
10+
name string
11+
s KeycloakSliceHashDelimited
12+
want []byte
13+
wantErr bool
14+
}{
15+
{"should render null for nil slice", nil, []byte("null"), false},
16+
{"should render single item", KeycloakSliceHashDelimited{"https://app/redirect1"}, []byte("\"https://app/redirect1\""), false},
17+
{"should render two items", KeycloakSliceHashDelimited{"https://app/redirect1", "https://app/redirect2"}, []byte("\"https://app/redirect1##https://app/redirect2\""), false},
18+
}
19+
for _, tt := range tests {
20+
t.Run(tt.name, func(t *testing.T) {
21+
got, err := tt.s.MarshalJSON()
22+
if (err != nil) != tt.wantErr {
23+
t.Errorf("MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
24+
return
25+
}
26+
if !reflect.DeepEqual(got, tt.want) {
27+
t.Errorf("MarshalJSON() got = %v, want %v", string(got), string(tt.want))
28+
}
29+
})
30+
}
31+
}

0 commit comments

Comments
 (0)