diff --git a/internal/commands/project.go b/internal/commands/project.go index f5ce41bc0..d95638499 100644 --- a/internal/commands/project.go +++ b/internal/commands/project.go @@ -545,20 +545,22 @@ func toProjectViews(models []wrappers.ProjectResponseModel) []projectView { func toProjectView(model wrappers.ProjectResponseModel) projectView { //nolint:gocritic return projectView{ - ID: model.ID, - Name: model.Name, - CreatedAt: model.CreatedAt, - UpdatedAt: model.UpdatedAt, - Tags: model.Tags, - Groups: model.Groups, + ID: model.ID, + Name: model.Name, + CreatedAt: model.CreatedAt, + UpdatedAt: model.UpdatedAt, + Tags: model.Tags, + Groups: model.Groups, + ApplicationIds: model.ApplicationIds, } } type projectView struct { - ID string `format:"name:Project ID"` - Name string - CreatedAt time.Time `format:"name:Created at;time:01-02-06 15:04:05"` - UpdatedAt time.Time `format:"name:Updated at;time:01-02-06 15:04:05"` - Tags map[string]string - Groups []string + ID string `format:"name:Project ID"` + Name string + CreatedAt time.Time `format:"name:Created at;time:01-02-06 15:04:05"` + UpdatedAt time.Time `format:"name:Updated at;time:01-02-06 15:04:05"` + Tags map[string]string + Groups []string + ApplicationIds []string } diff --git a/test/integration/project_test.go b/test/integration/project_test.go index 7d2db4548..c78c75995 100644 --- a/test/integration/project_test.go +++ b/test/integration/project_test.go @@ -106,13 +106,17 @@ func TestProjectCreate_ApplicationDoesntExist_FailAndReturnErrorMessage(t *testi func TestProjectCreate_ApplicationExists_CreateProjectSuccessfully(t *testing.T) { - err, _ := executeCommand( + err, outBuffer := executeCommand( t, "project", "create", flag(params.FormatFlag), printer.FormatJSON, flag(params.ProjectName), projectNameRandom, flag(params.ApplicationName), "my-application", ) - + createdProject := wrappers.ProjectResponseModel{} + unmarshall(t, outBuffer, &createdProject, "Reading project create response JSON should pass") + defer deleteProject(t, createdProject.ID) assert.NilError(t, err) + assert.Assert(t, createdProject.ID != "", "Project ID should not be empty") + assert.Assert(t, len(createdProject.ApplicationIds) == 1, "The project must be connected to the application") } func TestCreateWithInvalidGroup(t *testing.T) { diff --git a/test/integration/scan_test.go b/test/integration/scan_test.go index 85efc568a..c8b6055de 100644 --- a/test/integration/scan_test.go +++ b/test/integration/scan_test.go @@ -90,10 +90,12 @@ func TestScanCreate_ExistingApplicationAndNotExistingProject_CreatingNewProjectA flag(params.SourcesFlag), ".", flag(params.ScanTypes), "sast", flag(params.BranchFlag), "dummy_branch", + flag(params.ScanInfoFormatFlag), printer.FormatJSON, } - - err, _ := executeCommand(t, args...) - assert.NilError(t, err) + scanID, projectID := executeCreateScan(t, args) + defer deleteProject(t, projectID) + assert.Assert(t, scanID != "", "Scan ID should not be empty") + assert.Assert(t, projectID != "", "Project ID should not be empty") } func TestScanCreate_ApplicationDoesntExist_FailScanWithError(t *testing.T) {