Closed pierDipi closed 2 months ago
For testing authentication added in https://github.com/knative-extensions/backstage-plugins/pull/66, we would need to:
The first point is quite involved and it requires a few steps to setup the jobs in knative/infra
knative/infra
[1]
func VerifyBackstageBackendAuthentication() *feature.Feature { f := feature.NewFeature() authenticatedClientName := feature.MakeRandomK8sName("authenticated-client") unauthenticatedClientName := feature.MakeRandomK8sName("unauthenticated-client") SAName := "test-service-account" SANamespace := "test-service-account" f.Setup("request with authenticated client", func(ctx context.Context, t feature.T) { tr := &authenticationv1.TokenRequest{ // TODO: fill up } tr, err := kubeclient.Get(ctx). CoreV1(). ServiceAccounts(SANamespace). CreateToken(ctx, SAName, tr, metav1.CreateOptions{}) if err != nil { t.Fatal("Failed to create token for SA", err) } eventshub.Install(authenticatedClientName, eventshub.StartSenderURL("TODO_backstage_backend_url"), eventshub.InputHeader("Authorization", "Bearer "+tr.Status.Token), eventshub.InputMethod("GET"), )(ctx, t) }) f.Setup("request with unauthenticated client", eventshub.Install( unauthenticatedClientName, eventshub.StartSenderURL("TODO_backstage_backend_url"), eventshub.InputMethod("GET")), ) f.Assert("assert response with authenticated client", assert.OnStore(authenticatedClientName). Match(assert.MatchKind(eventshub.EventResponse)). Match(assert.MatchStatusCode(202)). AtLeast(1)) f.Assert("assert response with unauthenticated client", assert.OnStore(unauthenticatedClientName). Match(assert.MatchKind(eventshub.EventResponse)). Match(assert.MatchStatusCode(401)). AtLeast(1)) return f }
/assign
For testing authentication added in https://github.com/knative-extensions/backstage-plugins/pull/66, we would need to:
The first point is quite involved and it requires a few steps to setup the jobs in
knative/infra
[1]