feat: improve python actions (#1083)

This commit is contained in:
Jonas Plum
2024-07-21 02:56:43 +02:00
committed by GitHub
parent 81bfbb2072
commit 91429effe2
55 changed files with 1143 additions and 585 deletions

View File

@@ -6,63 +6,60 @@ import (
)
func Test_Routes(t *testing.T) {
baseApp, adminToken, analystToken, baseAppCleanup := BaseApp(t)
defer baseAppCleanup()
t.Parallel()
testSets := []authMatrixText{
testSets := []catalystTest{
{
baseTest: BaseTest{
Name: "Root",
Method: http.MethodGet,
URL: "/",
TestAppFactory: AppFactory(baseApp),
Name: "Root",
Method: http.MethodGet,
URL: "/",
},
authBasedExpectations: []AuthBasedExpectation{
userTests: []UserTest{
{
Name: "Unauthorized",
ExpectedStatus: http.StatusFound,
},
{
Name: "Analyst",
RequestHeaders: map[string]string{"Authorization": analystToken},
AuthRecord: analystEmail,
ExpectedStatus: http.StatusFound,
},
{
Name: "Admin",
RequestHeaders: map[string]string{"Authorization": adminToken},
Admin: adminEmail,
ExpectedStatus: http.StatusFound,
},
},
},
{
baseTest: BaseTest{
Name: "Config",
Method: http.MethodGet,
URL: "/api/config",
TestAppFactory: AppFactory(baseApp),
Name: "Config",
Method: http.MethodGet,
URL: "/api/config",
},
authBasedExpectations: []AuthBasedExpectation{
userTests: []UserTest{
{
Name: "Unauthorized",
ExpectedStatus: http.StatusOK,
ExpectedContent: []string{
`"flags":null`,
`"flags":[]`,
},
},
{
Name: "Analyst",
RequestHeaders: map[string]string{"Authorization": analystToken},
AuthRecord: analystEmail,
ExpectedStatus: http.StatusOK,
ExpectedContent: []string{
`"flags":null`,
`"flags":[]`,
},
},
{
Name: "Admin",
RequestHeaders: map[string]string{"Authorization": adminToken},
Admin: adminEmail,
ExpectedStatus: http.StatusOK,
ExpectedContent: []string{
`"flags":null`,
`"flags":[]`,
},
},
},
@@ -70,9 +67,14 @@ func Test_Routes(t *testing.T) {
}
for _, testSet := range testSets {
t.Run(testSet.baseTest.Name, func(t *testing.T) {
for _, authBasedExpectation := range testSet.authBasedExpectations {
scenario := mergeScenario(testSet.baseTest, authBasedExpectation)
scenario.Test(t)
t.Parallel()
for _, userTest := range testSet.userTests {
t.Run(userTest.Name, func(t *testing.T) {
t.Parallel()
runMatrixTest(t, testSet.baseTest, userTest)
})
}
})
}