github.com/cilium/cilium@v1.16.2/pkg/auth/always_fail_authhandler_test.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package auth
     5  
     6  import (
     7  	"reflect"
     8  	"testing"
     9  )
    10  
    11  func Test_alwaysFailAuthHandler_authenticate(t *testing.T) {
    12  	tests := []struct {
    13  		name    string
    14  		want    *authResponse
    15  		wantErr bool
    16  	}{
    17  		{
    18  			name:    "Always fail",
    19  			want:    nil,
    20  			wantErr: true,
    21  		},
    22  	}
    23  	for _, tt := range tests {
    24  		t.Run(tt.name, func(t *testing.T) {
    25  			r := &alwaysFailAuthHandler{}
    26  			got, err := r.authenticate(&authRequest{
    27  				localIdentity:  1000,
    28  				remoteIdentity: 1001,
    29  				remoteNodeIP:   "::1",
    30  			})
    31  			if (err != nil) != tt.wantErr {
    32  				t.Errorf("alwaysFailAuthHandler.authenticate() error = %v, wantErr %v", err, tt.wantErr)
    33  				return
    34  			}
    35  			if !reflect.DeepEqual(got, tt.want) {
    36  				t.Errorf("alwaysFailAuthHandler.authenticate() = %v, want %v", got, tt.want)
    37  			}
    38  		})
    39  	}
    40  }