Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

feat: Resource service endpoint handler implementation(#6346) #6461

Merged
merged 44 commits into from
Jan 4, 2022
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1a52759
added swagger doc comments for resource handler endpoints
bacherfl Dec 21, 2021
96e8176
added interface definitions and error types
bacherfl Dec 22, 2021
e375158
added unit tests for project/stage handlers
bacherfl Dec 22, 2021
cf3a1ce
added unit tests for project/stage/service handlers
bacherfl Dec 23, 2021
da5da84
added unit tests for project/stage/service handlers
bacherfl Dec 23, 2021
c3a7fa0
added unit tests for project resource handler
bacherfl Dec 23, 2021
a2ccc7d
refactoring, additional unit tests
bacherfl Dec 28, 2021
e623ead
refactoring, additional unit tests
bacherfl Dec 28, 2021
c74dd38
stage resource handler tests
bacherfl Dec 28, 2021
da55983
service resource handler implementation
bacherfl Dec 28, 2021
f6429d1
service resource handler unit tests
bacherfl Dec 28, 2021
973cda6
added stubs for implementations
bacherfl Dec 28, 2021
c0f357a
added utils
bacherfl Dec 29, 2021
2503a9b
implemented and tested project manager
bacherfl Dec 29, 2021
10ecdf2
implemented and tested stage/service manager
bacherfl Dec 29, 2021
a66abd9
feat: added API documentation (#6448)
odubajDT Dec 29, 2021
6b821b1
unit tests for service manager
bacherfl Dec 29, 2021
fdc8be3
Merge remote-tracking branch 'origin/feat/resource-service-endpoints'…
bacherfl Dec 29, 2021
c00b434
introduce response type for write operations
bacherfl Dec 30, 2021
e0edebf
refactorings
bacherfl Dec 30, 2021
0dfe382
refactorings
bacherfl Dec 30, 2021
a9129e9
extract common functionality to resource_engine
bacherfl Dec 30, 2021
94d161c
extract common functionality
bacherfl Dec 30, 2021
48ebb2d
adapted return types of write resource handlers
bacherfl Dec 30, 2021
352a6a9
introduce general resource manager
bacherfl Dec 30, 2021
14ee4c4
additional tests
bacherfl Dec 30, 2021
3678ebf
additional tests
bacherfl Dec 30, 2021
6034842
additional tests
bacherfl Dec 30, 2021
3bca769
introduce constants for common error messages
bacherfl Jan 3, 2022
2362dc2
add resource service to built artifacts
bacherfl Jan 3, 2022
1a9e78d
move gitignore file
bacherfl Jan 3, 2022
8bb3b77
additional tests
bacherfl Jan 3, 2022
5979874
Merge branch 'master' into feat/resource-service-endpoints
bacherfl Jan 3, 2022
4f8c9f9
remove obsolete code
bacherfl Jan 3, 2022
a8fce8d
additional tests
bacherfl Jan 3, 2022
955c401
wire up components
bacherfl Jan 4, 2022
cdbd8ea
additional tests for increased coverage
bacherfl Jan 4, 2022
5545f7a
introduce type for common properties
bacherfl Jan 4, 2022
cfb2be0
error logging
bacherfl Jan 4, 2022
ccb9d48
remove parseDependency flag from swag init
bacherfl Jan 4, 2022
4eb346d
Merge branch 'master' into feat/resource-service-endpoints
bacherfl Jan 4, 2022
f8d751f
fixed merge conflicts
bacherfl Jan 4, 2022
0e2c347
clean up todos
bacherfl Jan 4, 2022
d6af1c3
feat: added API documentation (#6448)
odubajDT Dec 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
additional tests
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
  • Loading branch information
bacherfl committed Jan 3, 2022
commit 6034842e5b0b7b46b4779ce4e4f31025a2a349eb
3 changes: 0 additions & 3 deletions resource-service/handler/resource_manager.go
Original file line number Diff line number Diff line change
@@ -91,9 +91,6 @@ func (p ResourceManager) GetResource(params models.GetResourceParams) (*models.G
}

resourcePath := configPath + "/" + unescapedResourceName
if !p.fileSystem.FileExists(resourcePath) {
return nil, errors.ErrResourceNotFound
}

return p.readResource(gitContext, params, resourcePath)
}
52 changes: 52 additions & 0 deletions resource-service/handler/resource_manager_test.go
Original file line number Diff line number Diff line change
@@ -700,6 +700,7 @@ func TestResourceManager_GetResource_ProjectResource(t *testing.T) {
require.Equal(t, fields.git.CheckoutBranchCalls()[0].Branch, "main")

require.Empty(t, fields.git.GetFileRevisionCalls())
require.Len(t, fields.fileSystem.ReadFileCalls(), 1)
}

func TestResourceManager_GetResource_ProjectResource_ProvideGitCommitID(t *testing.T) {
@@ -737,6 +738,57 @@ func TestResourceManager_GetResource_ProjectResource_ProvideGitCommitID(t *testi
require.Equal(t, "my-commit-id", fields.git.GetFileRevisionCalls()[0].Revision)
}

func TestResourceManager_GetResource_ProjectResource_ProjectNotFound(t *testing.T) {
fields := getTestResourceManagerFields()

fields.git.ProjectExistsFunc = func(gitContext common.GitContext) bool {
return false
}
rm := NewResourceManager(fields.git, fields.credentialReader, fields.fileSystem)

result, err := rm.GetResource(models.GetResourceParams{
Project: models.Project{
ProjectName: "my-project",
},
ResourceURI: "file1",
GetResourceQuery: models.GetResourceQuery{
GitCommitID: "my-commit-id",
},
})

require.NotNil(t, err)

require.Nil(t, result)

require.Empty(t, fields.git.CheckoutBranchCalls())
require.Empty(t, fields.git.GetFileRevisionCalls())
}

func TestResourceManager_GetResource_ProjectResource_InvalidResourceName(t *testing.T) {
fields := getTestResourceManagerFields()

rm := NewResourceManager(fields.git, fields.credentialReader, fields.fileSystem)

result, err := rm.GetResource(models.GetResourceParams{
Project: models.Project{
ProjectName: "my-project",
},
ResourceURI: "fi%le1",
GetResourceQuery: models.GetResourceQuery{
GitCommitID: "my-commit-id",
},
})

require.ErrorIs(t, err, errors2.ErrResourceInvalidResourceURI)

require.Nil(t, result)

require.Len(t, fields.git.CheckoutBranchCalls(), 1)
require.Equal(t, fields.git.CheckoutBranchCalls()[0].Branch, "main")

require.Empty(t, fields.git.GetFileRevisionCalls())
}

type fakeFileInfo struct {
name string
isDir bool