github.com/openshift/installer@v1.4.17/pkg/asset/agent/gencrypto/authconfig_test.go (about)

     1  package gencrypto
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  
     9  	"github.com/openshift/installer/pkg/asset"
    10  	"github.com/openshift/installer/pkg/asset/agent/common"
    11  	"github.com/openshift/installer/pkg/asset/agent/workflow"
    12  )
    13  
    14  func TestAuthConfig_Generate(t *testing.T) {
    15  	cases := []struct {
    16  		name     string
    17  		workflow workflow.AgentWorkflowType
    18  	}{
    19  		{
    20  			name:     "generate-public-key-and-token-install-workflow",
    21  			workflow: workflow.AgentWorkflowTypeInstall,
    22  		},
    23  	}
    24  	for _, tc := range cases {
    25  		t.Run(tc.name, func(t *testing.T) {
    26  			agentWorkflow := &workflow.AgentWorkflow{Workflow: tc.workflow}
    27  			parents := asset.Parents{}
    28  			parents.Add(&common.InfraEnvID{}, agentWorkflow)
    29  
    30  			authConfigAsset := &AuthConfig{}
    31  			err := authConfigAsset.Generate(context.Background(), parents)
    32  			assert.NoError(t, err)
    33  			assert.NotEmpty(t, authConfigAsset.PublicKey)
    34  			assert.NotEmpty(t, authConfigAsset.AgentAuthToken)
    35  		})
    36  	}
    37  }