update tests to match new method signatures

This commit is contained in:
tradel 2019-08-27 14:16:39 -07:00
parent 93c839b76c
commit 2838a1550a
3 changed files with 12 additions and 11 deletions

View File

@ -69,13 +69,14 @@ func TestAutoEncryptSign(t *testing.T) {
Datacenter: "dc1", Datacenter: "dc1",
Agent: "uuid", Agent: "uuid",
} }
commonName := fmt.Sprintf("%s.agent.%s.%s", id.Agent, id.Datacenter, "consul")
// Create a new private key // Create a new private key
pk, _, err := connect.GeneratePrivateKey() pk, _, err := connect.GeneratePrivateKey()
require.NoError(t, err, info) require.NoError(t, err, info)
// Create a CSR. // Create a CSR.
csr, err := connect.CreateCSR(id, pk) csr, err := connect.CreateCSR(id, commonName, pk)
require.NoError(t, err, info) require.NoError(t, err, info)
require.NotEmpty(t, csr, info) require.NotEmpty(t, csr, info)
args := &structs.CASignRequest{ args := &structs.CASignRequest{

View File

@ -246,7 +246,7 @@ func TestConnectCAConfig_TriggerRotation(t *testing.T) {
{ {
// Generate a CSR and request signing // Generate a CSR and request signing
spiffeId := connect.TestSpiffeIDService(t, "web") spiffeId := connect.TestSpiffeIDService(t, "web")
csr, _ := connect.TestCSR(t, spiffeId) csr, _ := connect.TestCSR(t, spiffeId, "node1.web.service.dc1.consul.")
args := &structs.CASignRequest{ args := &structs.CASignRequest{
Datacenter: "dc1", Datacenter: "dc1",
CSR: csr, CSR: csr,
@ -309,7 +309,7 @@ func TestConnectCASign(t *testing.T) {
// Generate a CSR and request signing // Generate a CSR and request signing
spiffeId := connect.TestSpiffeIDService(t, "web") spiffeId := connect.TestSpiffeIDService(t, "web")
csr, _ := connect.TestCSR(t, spiffeId) csr, _ := connect.TestCSR(t, spiffeId, "node1.web.service.dc1.consul.")
args := &structs.CASignRequest{ args := &structs.CASignRequest{
Datacenter: "dc1", Datacenter: "dc1",
CSR: csr, CSR: csr,
@ -319,7 +319,7 @@ func TestConnectCASign(t *testing.T) {
// Generate a second CSR and request signing // Generate a second CSR and request signing
spiffeId2 := connect.TestSpiffeIDService(t, "web2") spiffeId2 := connect.TestSpiffeIDService(t, "web2")
csr, _ = connect.TestCSR(t, spiffeId2) csr, _ = connect.TestCSR(t, spiffeId2, "node1.web2.service.dc1.consul.")
args = &structs.CASignRequest{ args = &structs.CASignRequest{
Datacenter: "dc1", Datacenter: "dc1",
CSR: csr, CSR: csr,
@ -366,7 +366,7 @@ func BenchmarkConnectCASign(b *testing.B) {
// Generate a CSR and request signing // Generate a CSR and request signing
spiffeID := connect.TestSpiffeIDService(b, "web") spiffeID := connect.TestSpiffeIDService(b, "web")
csr, _ := connect.TestCSR(b, spiffeID) csr, _ := connect.TestCSR(b, spiffeID, "node1.web.service.dc1.consul.")
args := &structs.CASignRequest{ args := &structs.CASignRequest{
Datacenter: "dc1", Datacenter: "dc1",
CSR: csr, CSR: csr,
@ -406,7 +406,7 @@ func TestConnectCASign_rateLimit(t *testing.T) {
// Generate a CSR and request signing a few times in a loop. // Generate a CSR and request signing a few times in a loop.
spiffeID := connect.TestSpiffeIDService(t, "web") spiffeID := connect.TestSpiffeIDService(t, "web")
csr, _ := connect.TestCSR(t, spiffeID) csr, _ := connect.TestCSR(t, spiffeID, "node1.web.service.dc1.consul.")
args := &structs.CASignRequest{ args := &structs.CASignRequest{
Datacenter: "dc1", Datacenter: "dc1",
CSR: csr, CSR: csr,
@ -460,7 +460,7 @@ func TestConnectCASign_concurrencyLimit(t *testing.T) {
// Generate a CSR and request signing a few times in a loop. // Generate a CSR and request signing a few times in a loop.
spiffeID := connect.TestSpiffeIDService(t, "web") spiffeID := connect.TestSpiffeIDService(t, "web")
csr, _ := connect.TestCSR(t, spiffeID) csr, _ := connect.TestCSR(t, spiffeID, "node1.web.service.dc1.consul.")
args := &structs.CASignRequest{ args := &structs.CASignRequest{
Datacenter: "dc1", Datacenter: "dc1",
CSR: csr, CSR: csr,
@ -625,7 +625,7 @@ func TestConnectCASignValidation(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
csr, _ := connect.TestCSR(t, tt.id) csr, _ := connect.TestCSR(t, tt.id, "")
args := &structs.CASignRequest{ args := &structs.CASignRequest{
Datacenter: "dc1", Datacenter: "dc1",
CSR: csr, CSR: csr,

View File

@ -86,7 +86,7 @@ func TestLeader_SecondaryCA_Initialize(t *testing.T) {
Datacenter: "primary", Datacenter: "primary",
Service: "foo", Service: "foo",
} }
raw, _ := connect.TestCSR(t, spiffeService) raw, _ := connect.TestCSR(t, spiffeService, "node1.foo.service.primary.consul.")
leafCsr, err := connect.ParseCSR(raw) leafCsr, err := connect.ParseCSR(raw)
require.NoError(err) require.NoError(err)
@ -216,7 +216,7 @@ func TestLeader_SecondaryCA_IntermediateRefresh(t *testing.T) {
Datacenter: "dc1", Datacenter: "dc1",
Service: "foo", Service: "foo",
} }
raw, _ := connect.TestCSR(t, spiffeService) raw, _ := connect.TestCSR(t, spiffeService, "node1.foo.service.primary.consul.")
leafCsr, err := connect.ParseCSR(raw) leafCsr, err := connect.ParseCSR(raw)
require.NoError(err) require.NoError(err)
@ -434,7 +434,7 @@ func TestLeader_SecondaryCA_UpgradeBeforePrimary(t *testing.T) {
Datacenter: "dc1", Datacenter: "dc1",
Service: "foo", Service: "foo",
} }
raw, _ := connect.TestCSR(t, spiffeService) raw, _ := connect.TestCSR(t, spiffeService, "node1.foo.service.primary.consul.")
leafCsr, err := connect.ParseCSR(raw) leafCsr, err := connect.ParseCSR(raw)
require.NoError(t, err) require.NoError(t, err)