Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhbh committed Nov 19, 2024
1 parent e1d6821 commit cd35cd3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
13 changes: 9 additions & 4 deletions internal/cognito/server/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var _ = Describe("Server", func() {
mockCognitoClient *mock_server.MockCognitoClient
ctx context.Context
applicationClientId = "client-internal-id"
testToken = "test"
)

BeforeEach(func() {
Expand Down Expand Up @@ -85,6 +86,9 @@ var _ = Describe("Server", func() {
Body: &portalv1.CreateOAuthApplicationJSONRequestBody{
Id: applicationClientId,
},
Params: portalv1.CreateOAuthApplicationParams{
Token: &testToken,
},
})
Expect(err).NotTo(HaveOccurred())
Expect(resp).To(BeAssignableToTypeOf(portalv1.CreateOAuthApplication201JSONResponse{}))
Expand All @@ -101,10 +105,9 @@ var _ = Describe("Server", func() {
})

It("returns an error code on empty client id", func() {
token := "test"
resp, err := s.CreateOAuthApplication(ctx, portalv1.CreateOAuthApplicationRequestObject{
Params: portalv1.CreateOAuthApplicationParams{
Token: &token,
Token: &testToken,
},
Body: &portalv1.CreateOAuthApplicationJSONRequestBody{
Id: "",
Expand All @@ -117,6 +120,9 @@ var _ = Describe("Server", func() {
It("returns not found code on deletion", func() {
resp, err := s.DeleteOAuthApplication(ctx, portalv1.DeleteOAuthApplicationRequestObject{
Id: "test-client",
Params: portalv1.DeleteOAuthApplicationParams{
Token: &testToken,
},
})
Expect(err).NotTo(HaveOccurred())
Expect(resp).To(BeAssignableToTypeOf(portalv1.DeleteOAuthApplication404JSONResponse{}))
Expand Down Expand Up @@ -156,11 +162,10 @@ var _ = Describe("Server", func() {
})

It("can delete the client", func() {
token := "test"
resp, err := s.DeleteOAuthApplication(ctx, portalv1.DeleteOAuthApplicationRequestObject{
Id: clientId,
Params: portalv1.DeleteOAuthApplicationParams{
Token: &token,
Token: &testToken,
},
})
Expect(err).NotTo(HaveOccurred())
Expand Down
13 changes: 13 additions & 0 deletions internal/keycloak/server/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var _ = Describe("Server", func() {
Name: applicationClientId,
Secret: applicationClientSecret,
}
testToken = "test"
)

BeforeEach(func() {
Expand Down Expand Up @@ -80,6 +81,9 @@ var _ = Describe("Server", func() {
Body: &portalv1.CreateOAuthApplicationJSONRequestBody{
Id: applicationClientId,
},
Params: portalv1.CreateOAuthApplicationParams{
Token: &testToken,
},
})
Expect(err).NotTo(HaveOccurred())
Expect(resp).To(BeAssignableToTypeOf(portalv1.CreateOAuthApplication201JSONResponse{}))
Expand All @@ -100,6 +104,9 @@ var _ = Describe("Server", func() {
Body: &portalv1.CreateOAuthApplicationJSONRequestBody{
Id: "",
},
Params: portalv1.CreateOAuthApplicationParams{
Token: &testToken,
},
})
Expect(err).NotTo(HaveOccurred())
Expect(resp).To(BeAssignableToTypeOf(portalv1.CreateOAuthApplication400JSONResponse{}))
Expand All @@ -108,6 +115,9 @@ var _ = Describe("Server", func() {
It("returns not found code on deletion", func() {
resp, err := s.DeleteOAuthApplication(ctx, portalv1.DeleteOAuthApplicationRequestObject{
Id: "non-existing-client",
Params: portalv1.DeleteOAuthApplicationParams{
Token: &testToken,
},
})
Expect(err).NotTo(HaveOccurred())
Expect(resp).To(BeAssignableToTypeOf(portalv1.DeleteOAuthApplication404JSONResponse{}))
Expand All @@ -128,6 +138,9 @@ var _ = Describe("Server", func() {
It("can delete the client", func() {
resp, err := s.DeleteOAuthApplication(ctx, portalv1.DeleteOAuthApplicationRequestObject{
Id: applicationClientId,
Params: portalv1.DeleteOAuthApplicationParams{
Token: &testToken,
},
})
Expect(err).NotTo(HaveOccurred())
Expect(resp).To(BeAssignableToTypeOf(portalv1.DeleteOAuthApplication204Response{}))
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var _ = Describe("E2e", Ordered, func() {
Method: "POST",
Data: fmt.Sprintf(`{"id": "%s"}`, internalClientId),
App: "curl",
Headers: []string{"Content-Type: application/json", "token: test"},
Headers: []string{"Content-Type: application/json"},
}

out, err := curlFromPod.Execute()
Expand All @@ -59,7 +59,6 @@ var _ = Describe("E2e", Ordered, func() {
Method: "DELETE",
Verbose: true,
App: "curl",
Headers: []string{"token: test"},
}

out, err := curlFromPod.Execute()
Expand Down

0 comments on commit cd35cd3

Please sign in to comment.