mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 05:37:43 +00:00
feat: App Keys API v2 (#10140)
# Which Problems Are Solved This PR *partially* addresses #9450 . Specifically, it implements the resource based API for app keys. This PR, together with https://github.com/zitadel/zitadel/pull/10077 completes #9450 . # How the Problems Are Solved - Implementation of the following endpoints: `CreateApplicationKey`, `DeleteApplicationKey`, `GetApplicationKey`, `ListApplicationKeys` - `ListApplicationKeys` can filter by project, app or organization ID. Sorting is also possible according to some criteria. - All endpoints use permissions V2 # TODO - [x] Deprecate old endpoints # Additional Context Closes #9450
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
@@ -147,3 +148,71 @@ func Test_apiAuthMethodTypeToPb(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
func TestGetApplicationKeyQueriesRequestToDomain(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tt := []struct {
|
||||
testName string
|
||||
inputOrgID string
|
||||
inputProjectID string
|
||||
inputAppID string
|
||||
|
||||
expectedQueriesLength int
|
||||
}{
|
||||
{
|
||||
testName: "all IDs provided",
|
||||
inputOrgID: "org-1",
|
||||
inputProjectID: "proj-1",
|
||||
inputAppID: "app-1",
|
||||
expectedQueriesLength: 3,
|
||||
},
|
||||
{
|
||||
testName: "only org ID",
|
||||
inputOrgID: "org-1",
|
||||
inputProjectID: " ",
|
||||
inputAppID: "",
|
||||
expectedQueriesLength: 1,
|
||||
},
|
||||
{
|
||||
testName: "only project ID",
|
||||
inputOrgID: "",
|
||||
inputProjectID: "proj-1",
|
||||
inputAppID: " ",
|
||||
expectedQueriesLength: 1,
|
||||
},
|
||||
{
|
||||
testName: "only app ID",
|
||||
inputOrgID: " ",
|
||||
inputProjectID: "",
|
||||
inputAppID: "app-1",
|
||||
expectedQueriesLength: 1,
|
||||
},
|
||||
{
|
||||
testName: "empty IDs",
|
||||
inputOrgID: " ",
|
||||
inputProjectID: " ",
|
||||
inputAppID: " ",
|
||||
expectedQueriesLength: 0,
|
||||
},
|
||||
{
|
||||
testName: "with spaces",
|
||||
inputOrgID: " org-1 ",
|
||||
inputProjectID: " proj-1 ",
|
||||
inputAppID: " app-1 ",
|
||||
expectedQueriesLength: 3,
|
||||
},
|
||||
}
|
||||
for _, tc := range tt {
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// When
|
||||
got, err := GetApplicationKeyQueriesRequestToDomain(tc.inputOrgID, tc.inputProjectID, tc.inputAppID)
|
||||
|
||||
// Then
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Len(t, got, tc.expectedQueriesLength)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user