mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-15 18:20:18 -04:00
fixed tests
This commit is contained in:
parent
570b735e09
commit
5053c4581d
1 changed files with 42 additions and 9 deletions
|
@ -50,6 +50,11 @@ func TestClient(t *testing.T) {
|
||||||
{Role: role.ControlPlane, Name: "node-4", VPCIP: "192.0.2.2"},
|
{Role: role.ControlPlane, Name: "node-4", VPCIP: "192.0.2.2"},
|
||||||
{Role: role.ControlPlane, Name: "node-5", VPCIP: "192.0.2.3"},
|
{Role: role.ControlPlane, Name: "node-5", VPCIP: "192.0.2.3"},
|
||||||
}
|
}
|
||||||
|
caDerivationKey := make([]byte, 256)
|
||||||
|
for i := range caDerivationKey {
|
||||||
|
caDerivationKey[i] = 0x0
|
||||||
|
}
|
||||||
|
respCaKey := &joinproto.IssueJoinTicketResponse{EmergencyCaKey: caDerivationKey}
|
||||||
|
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
role role.Role
|
role role.Role
|
||||||
|
@ -69,7 +74,7 @@ func TestClient(t *testing.T) {
|
||||||
selfAnswer{err: assert.AnError},
|
selfAnswer{err: assert.AnError},
|
||||||
selfAnswer{instance: workerSelf},
|
selfAnswer{instance: workerSelf},
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{},
|
issueJoinTicketAnswer{resp: respCaKey},
|
||||||
},
|
},
|
||||||
clusterJoiner: &stubClusterJoiner{},
|
clusterJoiner: &stubClusterJoiner{},
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
|
@ -85,7 +90,7 @@ func TestClient(t *testing.T) {
|
||||||
selfAnswer{instance: metadata.InstanceMetadata{Name: "node-1"}},
|
selfAnswer{instance: metadata.InstanceMetadata{Name: "node-1"}},
|
||||||
selfAnswer{instance: workerSelf},
|
selfAnswer{instance: workerSelf},
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{},
|
issueJoinTicketAnswer{resp: respCaKey},
|
||||||
},
|
},
|
||||||
clusterJoiner: &stubClusterJoiner{},
|
clusterJoiner: &stubClusterJoiner{},
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
|
@ -101,7 +106,7 @@ func TestClient(t *testing.T) {
|
||||||
listAnswer{err: assert.AnError},
|
listAnswer{err: assert.AnError},
|
||||||
listAnswer{err: assert.AnError},
|
listAnswer{err: assert.AnError},
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{},
|
issueJoinTicketAnswer{resp: respCaKey},
|
||||||
},
|
},
|
||||||
clusterJoiner: &stubClusterJoiner{},
|
clusterJoiner: &stubClusterJoiner{},
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
|
@ -117,7 +122,7 @@ func TestClient(t *testing.T) {
|
||||||
listAnswer{},
|
listAnswer{},
|
||||||
listAnswer{},
|
listAnswer{},
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{},
|
issueJoinTicketAnswer{resp: respCaKey},
|
||||||
},
|
},
|
||||||
clusterJoiner: &stubClusterJoiner{},
|
clusterJoiner: &stubClusterJoiner{},
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
|
@ -134,7 +139,7 @@ func TestClient(t *testing.T) {
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{err: assert.AnError},
|
issueJoinTicketAnswer{err: assert.AnError},
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{},
|
issueJoinTicketAnswer{resp: respCaKey},
|
||||||
},
|
},
|
||||||
clusterJoiner: &stubClusterJoiner{},
|
clusterJoiner: &stubClusterJoiner{},
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
|
@ -142,6 +147,22 @@ func TestClient(t *testing.T) {
|
||||||
wantJoin: true,
|
wantJoin: true,
|
||||||
wantLock: true,
|
wantLock: true,
|
||||||
},
|
},
|
||||||
|
"on worker: no CA derivation key is given": {
|
||||||
|
role: role.Worker,
|
||||||
|
apiAnswers: []any{
|
||||||
|
selfAnswer{instance: workerSelf},
|
||||||
|
listAnswer{instances: peers},
|
||||||
|
issueJoinTicketAnswer{err: assert.AnError},
|
||||||
|
listAnswer{instances: peers},
|
||||||
|
issueJoinTicketAnswer{err: assert.AnError},
|
||||||
|
listAnswer{instances: peers},
|
||||||
|
issueJoinTicketAnswer{},
|
||||||
|
},
|
||||||
|
clusterJoiner: &stubClusterJoiner{},
|
||||||
|
nodeLock: newFakeLock(),
|
||||||
|
disk: &stubDisk{},
|
||||||
|
wantLock: true,
|
||||||
|
},
|
||||||
"on control plane: issueJoinTicket errors": {
|
"on control plane: issueJoinTicket errors": {
|
||||||
role: role.ControlPlane,
|
role: role.ControlPlane,
|
||||||
apiAnswers: []any{
|
apiAnswers: []any{
|
||||||
|
@ -151,7 +172,7 @@ func TestClient(t *testing.T) {
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{err: assert.AnError},
|
issueJoinTicketAnswer{err: assert.AnError},
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{},
|
issueJoinTicketAnswer{resp: respCaKey},
|
||||||
},
|
},
|
||||||
clusterJoiner: &stubClusterJoiner{},
|
clusterJoiner: &stubClusterJoiner{},
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
|
@ -164,7 +185,7 @@ func TestClient(t *testing.T) {
|
||||||
apiAnswers: []any{
|
apiAnswers: []any{
|
||||||
selfAnswer{instance: controlSelf},
|
selfAnswer{instance: controlSelf},
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{},
|
issueJoinTicketAnswer{resp: respCaKey},
|
||||||
},
|
},
|
||||||
clusterJoiner: &stubClusterJoiner{numBadCalls: -1, joinClusterErr: assert.AnError},
|
clusterJoiner: &stubClusterJoiner{numBadCalls: -1, joinClusterErr: assert.AnError},
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
|
@ -177,7 +198,7 @@ func TestClient(t *testing.T) {
|
||||||
apiAnswers: []any{
|
apiAnswers: []any{
|
||||||
selfAnswer{instance: controlSelf},
|
selfAnswer{instance: controlSelf},
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{},
|
issueJoinTicketAnswer{resp: respCaKey},
|
||||||
},
|
},
|
||||||
clusterJoiner: &stubClusterJoiner{numBadCalls: 1, joinClusterErr: assert.AnError},
|
clusterJoiner: &stubClusterJoiner{numBadCalls: 1, joinClusterErr: assert.AnError},
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
|
@ -186,13 +207,25 @@ func TestClient(t *testing.T) {
|
||||||
wantLock: true,
|
wantLock: true,
|
||||||
wantNumJoins: 2,
|
wantNumJoins: 2,
|
||||||
},
|
},
|
||||||
"on control plane: node already locked": {
|
"on control plane: no CA derivation key is given": {
|
||||||
role: role.ControlPlane,
|
role: role.ControlPlane,
|
||||||
apiAnswers: []any{
|
apiAnswers: []any{
|
||||||
selfAnswer{instance: controlSelf},
|
selfAnswer{instance: controlSelf},
|
||||||
listAnswer{instances: peers},
|
listAnswer{instances: peers},
|
||||||
issueJoinTicketAnswer{},
|
issueJoinTicketAnswer{},
|
||||||
},
|
},
|
||||||
|
clusterJoiner: &stubClusterJoiner{numBadCalls: 1, joinClusterErr: assert.AnError},
|
||||||
|
nodeLock: newFakeLock(),
|
||||||
|
disk: &stubDisk{},
|
||||||
|
wantLock: true,
|
||||||
|
},
|
||||||
|
"on control plane: node already locked": {
|
||||||
|
role: role.ControlPlane,
|
||||||
|
apiAnswers: []any{
|
||||||
|
selfAnswer{instance: controlSelf},
|
||||||
|
listAnswer{instances: peers},
|
||||||
|
issueJoinTicketAnswer{resp: respCaKey},
|
||||||
|
},
|
||||||
clusterJoiner: &stubClusterJoiner{},
|
clusterJoiner: &stubClusterJoiner{},
|
||||||
nodeLock: lockedLock,
|
nodeLock: lockedLock,
|
||||||
disk: &stubDisk{},
|
disk: &stubDisk{},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue