fix crl not reload when crl got updated in the ca secret
This commit is contained in:
parent
5f1a37a624
commit
4ddb0c724a
3 changed files with 155 additions and 1 deletions
|
@ -457,8 +457,8 @@ func New(
|
||||||
klog.ErrorS(err, "could not find Ingress in local store", "ingress", ingKey)
|
klog.ErrorS(err, "could not find Ingress in local store", "ingress", ingKey)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
store.syncIngress(ing)
|
|
||||||
store.syncSecrets(ing)
|
store.syncSecrets(ing)
|
||||||
|
store.syncIngress(ing)
|
||||||
}
|
}
|
||||||
updateCh.In() <- Event{
|
updateCh.In() <- Event{
|
||||||
Type: UpdateEvent,
|
Type: UpdateEvent,
|
||||||
|
|
|
@ -549,6 +549,9 @@ func (s1 *SSLCert) Equal(s2 *SSLCert) bool {
|
||||||
if s1.CASHA != s2.CASHA {
|
if s1.CASHA != s2.CASHA {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if s1.CRLSHA != s2.CRLSHA {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if s1.PemSHA != s2.PemSHA {
|
if s1.PemSHA != s2.PemSHA {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEqualConfiguration(t *testing.T) {
|
func TestEqualConfiguration(t *testing.T) {
|
||||||
|
@ -142,3 +143,153 @@ func TestIntElementsMatch(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSSLCertMatch(t *testing.T) {
|
||||||
|
now := time.Now()
|
||||||
|
cert := &SSLCert{
|
||||||
|
UID: "1",
|
||||||
|
Name: "nameA",
|
||||||
|
Namespace: "namespaceA",
|
||||||
|
CASHA: "CASHA_A",
|
||||||
|
CN: []string{"CommonNameA"},
|
||||||
|
CRLSHA: "CRLSHA_A",
|
||||||
|
PemSHA: "PemSHA_A",
|
||||||
|
PemCertKey: "PemKeyA",
|
||||||
|
ExpireTime: now,
|
||||||
|
}
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
sslCertA *SSLCert
|
||||||
|
sslCertB *SSLCert
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{cert, cert, true},
|
||||||
|
{
|
||||||
|
cert,
|
||||||
|
&SSLCert{
|
||||||
|
UID: "1",
|
||||||
|
Name: "nameA",
|
||||||
|
Namespace: "namespaceA",
|
||||||
|
CASHA: "CASHA_A",
|
||||||
|
CN: []string{"CommonNameA"},
|
||||||
|
CRLSHA: "CRLSHA_A",
|
||||||
|
PemSHA: "PemSHA_A",
|
||||||
|
PemCertKey: "PemKeyA",
|
||||||
|
ExpireTime: now,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cert,
|
||||||
|
&SSLCert{
|
||||||
|
UID: "1",
|
||||||
|
Name: "nameA",
|
||||||
|
Namespace: "namespaceA",
|
||||||
|
CASHA: "CASHA_New",
|
||||||
|
CN: []string{"CommonNameA"},
|
||||||
|
CRLSHA: "CRLSHA_A",
|
||||||
|
PemSHA: "PemSHA_A",
|
||||||
|
PemCertKey: "PemKeyA",
|
||||||
|
ExpireTime: now,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cert,
|
||||||
|
&SSLCert{
|
||||||
|
UID: "1",
|
||||||
|
Name: "nameA",
|
||||||
|
Namespace: "namespaceA",
|
||||||
|
CASHA: "CASHA_A",
|
||||||
|
CN: []string{"CommonNameA"},
|
||||||
|
CRLSHA: "CRLSHA_NEW",
|
||||||
|
PemSHA: "PemSHA_A",
|
||||||
|
PemCertKey: "PemKeyA",
|
||||||
|
ExpireTime: now,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cert,
|
||||||
|
&SSLCert{
|
||||||
|
UID: "1",
|
||||||
|
Name: "nameA",
|
||||||
|
Namespace: "namespaceA",
|
||||||
|
CASHA: "CASHA_A",
|
||||||
|
CN: []string{"CommonNameA"},
|
||||||
|
CRLSHA: "CRLSHA_A",
|
||||||
|
PemSHA: "PemSHA_New",
|
||||||
|
PemCertKey: "PemKeyA",
|
||||||
|
ExpireTime: now,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cert,
|
||||||
|
&SSLCert{
|
||||||
|
UID: "1",
|
||||||
|
Name: "nameA",
|
||||||
|
Namespace: "namespaceA",
|
||||||
|
CASHA: "CASHA_A",
|
||||||
|
CN: []string{"CommonNameNew"},
|
||||||
|
CRLSHA: "CRLSHA_A",
|
||||||
|
PemSHA: "PemSHA_A",
|
||||||
|
PemCertKey: "PemKeyA",
|
||||||
|
ExpireTime: now,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cert,
|
||||||
|
&SSLCert{
|
||||||
|
UID: "1",
|
||||||
|
Name: "nameA",
|
||||||
|
Namespace: "namespaceA",
|
||||||
|
CASHA: "CASHA_A",
|
||||||
|
CN: []string{"CommonNameA"},
|
||||||
|
CRLSHA: "CRLSHA_A",
|
||||||
|
PemSHA: "PemSHA_A",
|
||||||
|
PemCertKey: "PemKeyA",
|
||||||
|
ExpireTime: now.Add(time.Minute),
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cert,
|
||||||
|
&SSLCert{
|
||||||
|
UID: "1",
|
||||||
|
Name: "nameA",
|
||||||
|
Namespace: "namespaceA",
|
||||||
|
CASHA: "CASHA_A",
|
||||||
|
CN: []string{"CommonNameA"},
|
||||||
|
CRLSHA: "CRLSHA_A",
|
||||||
|
PemSHA: "PemSHA_A",
|
||||||
|
PemCertKey: "PemKeyNew",
|
||||||
|
ExpireTime: now,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cert,
|
||||||
|
&SSLCert{
|
||||||
|
UID: "2",
|
||||||
|
Name: "nameA",
|
||||||
|
Namespace: "namespaceA",
|
||||||
|
CASHA: "CASHA_A",
|
||||||
|
CN: []string{"CommonNameA"},
|
||||||
|
CRLSHA: "CRLSHA_A",
|
||||||
|
PemSHA: "PemSHA_A",
|
||||||
|
PemCertKey: "PemKeyA",
|
||||||
|
ExpireTime: now,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
result := testCase.sslCertA.Equal(testCase.sslCertB)
|
||||||
|
if result != testCase.expected {
|
||||||
|
t.Errorf("expected %v but returned %v (%v - %v)", testCase.expected, result, testCase.sslCertA, testCase.sslCertB)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue