github.com/elfadel/cilium@v1.6.12/pkg/proxy/mock_test.go (about) 1 // Copyright 2017-2019 Authors of Cilium 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // +build !privileged_tests 16 17 package proxy 18 19 import ( 20 "github.com/cilium/cilium/pkg/identity" 21 "github.com/cilium/cilium/pkg/labels" 22 "github.com/cilium/cilium/pkg/lock" 23 "github.com/cilium/cilium/pkg/policy" 24 "github.com/cilium/cilium/pkg/proxy/accesslog" 25 ) 26 27 type proxyUpdaterMock struct { 28 lock.RWMutex 29 id uint64 30 ipv4 string 31 ipv6 string 32 labels []string 33 identity identity.NumericIdentity 34 hasSidecarProxy bool 35 } 36 37 func (m *proxyUpdaterMock) UnconditionalRLock() { m.RWMutex.RLock() } 38 func (m *proxyUpdaterMock) RUnlock() { m.RWMutex.RUnlock() } 39 40 func (m *proxyUpdaterMock) GetID() uint64 { return m.id } 41 func (m *proxyUpdaterMock) GetIPv4Address() string { return m.ipv4 } 42 func (m *proxyUpdaterMock) GetIPv6Address() string { return m.ipv6 } 43 func (m *proxyUpdaterMock) GetLabels() []string { return m.labels } 44 func (m *proxyUpdaterMock) GetEgressPolicyEnabledLocked() bool { return true } 45 func (m *proxyUpdaterMock) GetIngressPolicyEnabledLocked() bool { return true } 46 func (m *proxyUpdaterMock) GetIdentityLocked() identity.NumericIdentity { return m.identity } 47 func (m *proxyUpdaterMock) ProxyID(l4 *policy.L4Filter) string { return "" } 48 func (m *proxyUpdaterMock) GetLabelsSHA() string { 49 return labels.NewLabelsFromModel(m.labels).SHA256Sum() 50 } 51 func (m *proxyUpdaterMock) HasSidecarProxy() bool { return m.hasSidecarProxy } 52 func (m *proxyUpdaterMock) ConntrackName() string { return "global" } 53 54 func (m *proxyUpdaterMock) OnProxyPolicyUpdate(policyRevision uint64) {} 55 func (m *proxyUpdaterMock) UpdateProxyStatistics(l4Protocol string, port uint16, ingress, request bool, 56 verdict accesslog.FlowVerdict) { 57 }