Skip to content

Commit

Permalink
Merge branch 'istio-ecosystem:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
virajrk authored Jan 8, 2025
2 parents 3315337 + e885c76 commit 4c497b6
Show file tree
Hide file tree
Showing 17 changed files with 1,249 additions and 264 deletions.
13 changes: 0 additions & 13 deletions admiral/pkg/apis/admiral/filters/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,3 @@ func Logger(inner http.Handler, name string) http.Handler {
)
})
}

func Auth(inner http.Handler, name string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

log.Printf(
"Auth Logger for endpoint %s", name,
)
//TODO implement authnz

inner.ServeHTTP(w, r)

})
}
31 changes: 31 additions & 0 deletions admiral/pkg/clusters/sidecar_handler_test.go
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
package clusters

import (
"context"
"github.com/stretchr/testify/assert"
"istio.io/client-go/pkg/apis/networking/v1alpha3"
"testing"
)

func TestSidecarHandler_Added(t *testing.T) {
var dh SidecarHandler
var ctx context.Context
var obj *v1alpha3.Sidecar
err := dh.Added(ctx, obj)
assert.Nil(t, err)
}

func TestSidecarHandler_Updated(t *testing.T) {
var dh SidecarHandler
var ctx context.Context
var obj *v1alpha3.Sidecar
err := dh.Updated(ctx, obj)
assert.Nil(t, err)
}

func TestSidecarHandler_Deleted(t *testing.T) {
var dh SidecarHandler
var ctx context.Context
var obj *v1alpha3.Sidecar
err := dh.Deleted(ctx, obj)
assert.Nil(t, err)
}
35 changes: 35 additions & 0 deletions admiral/pkg/clusters/types_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package clusters

import (
"github.com/stretchr/testify/assert"
"sync"
"testing"
"time"

"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -42,3 +44,36 @@ func setupForTypeTests() {
common.InitializeConfig(admiralParamsForTypesTests())
})
}

func TestRangeRemoteControllers(t *testing.T) {
setupForTypeTests()

rr := &RemoteRegistry{
Mutex: sync.Mutex{},
remoteControllers: map[string]*RemoteController{"test": &RemoteController{}},
}

counter := 0
// testFunc is a function that tests the RemoteController
testFunc := func(k string, v *RemoteController) {
counter = counter + 1
}

// TestRangeRemoteControllers is a table-driven test for RangeRemoteControllers
tests := []struct {
name string
expected int
}{
{
name: "TestRangeRemoteControllers",
expected: 1,
},
}
for _, tt := range tests {
counter = 0
t.Run(tt.name, func(t *testing.T) {
rr.RangeRemoteControllers(testFunc)
assert.Equal(t, tt.expected, counter)
})
}
}
25 changes: 25 additions & 0 deletions admiral/pkg/controller/admiral/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admiral

import (
"context"
"github.com/istio-ecosystem/admiral/admiral/pkg/client/loader"
"testing"
"time"

Expand Down Expand Up @@ -172,3 +173,27 @@ func TestConfigMapController_PutConfigMap(t *testing.T) {
}

}

func TestNewConfigMapController(t *testing.T) {
clientLoader := &loader.FakeClientLoader{}
seIPPrefix := "prefix"
controller, err := NewConfigMapController(seIPPrefix, clientLoader)
if err != nil {
t.Errorf("No error expected. Err: %v", err)
}

if controller.ServiceEntryIPPrefix != seIPPrefix {
t.Errorf("Expected %v but got %v", seIPPrefix, controller.ServiceEntryIPPrefix)
}
}

func TestConfigMapController_GetIPPrefixForServiceEntries(t *testing.T) {
seIPPrefix := "prefix"
controller := ConfigMapController{
ServiceEntryIPPrefix: seIPPrefix,
}

if controller.GetIPPrefixForServiceEntries() != seIPPrefix {
t.Errorf("Expected %v but got %v", seIPPrefix, controller.GetIPPrefixForServiceEntries())
}
}
Loading

0 comments on commit 4c497b6

Please sign in to comment.