diff --git a/src/autoscaler/api/publicapiserver/public_api_server_test.go b/src/autoscaler/api/publicapiserver/public_api_server_test.go index 145d651af..6b2beba50 100644 --- a/src/autoscaler/api/publicapiserver/public_api_server_test.go +++ b/src/autoscaler/api/publicapiserver/public_api_server_test.go @@ -84,6 +84,9 @@ var _ = Describe("PublicApiServer", func() { BeforeEach(func() { fakeRateLimiter.ExceedsLimitReturns(true) }) + AfterEach(func() { + fakeRateLimiter.ExceedsLimitReturns(false) + }) Context("when calling scaling_histories endpoint", func() { It("should fail with 429", func() { @@ -147,10 +150,6 @@ var _ = Describe("PublicApiServer", func() { }) Describe("Without AuthorizatioToken", func() { - BeforeEach(func() { - fakeRateLimiter.ExceedsLimitReturns(false) - }) - Context("when calling scaling_histories endpoint", func() { It("should fail with 401", func() { verifyResponse(httpClient, serverUrl, "/v1/apps/"+TEST_APP_ID+"/scaling_histories", @@ -215,7 +214,6 @@ var _ = Describe("PublicApiServer", func() { Describe("With Invalid Authorization Token", func() { BeforeEach(func() { fakeCFClient.IsUserSpaceDeveloperReturns(false, nil) - fakeRateLimiter.ExceedsLimitReturns(false) }) Context("when calling scaling_histories endpoint", func() { @@ -299,7 +297,6 @@ var _ = Describe("PublicApiServer", func() { Describe("With valid authorization token", func() { BeforeEach(func() { fakeCFClient.IsUserSpaceDeveloperReturns(true, nil) - fakeRateLimiter.ExceedsLimitReturns(false) }) Context("when calling scaling_histories endpoint", func() { diff --git a/src/autoscaler/metricsforwarder/server/server_test.go b/src/autoscaler/metricsforwarder/server/server_test.go index b010536f6..f9965bfc8 100644 --- a/src/autoscaler/metricsforwarder/server/server_test.go +++ b/src/autoscaler/metricsforwarder/server/server_test.go @@ -26,7 +26,6 @@ var _ = Describe("CustomMetrics Server", func() { Context("when a request to forward custom metrics comes", func() { BeforeEach(func() { - rateLimiter.ExceedsLimitReturns(false) credentials = &models.Credential{} scalingPolicy = &models.ScalingPolicy{ InstanceMin: 1, @@ -66,7 +65,6 @@ var _ = Describe("CustomMetrics Server", func() { Context("when a request to forward custom metrics comes without Authorization header", func() { BeforeEach(func() { - rateLimiter.ExceedsLimitReturns(false) credentials = &models.Credential{} credentials.Username = "$2a$10$YnQNQYcvl/Q2BKtThOKFZ.KB0nTIZwhKr5q1pWTTwC/PUAHsbcpFu" credentials.Password = "$2a$10$6nZ73cm7IV26wxRnmm5E1.nbk9G.0a4MrbzBFPChkm5fPftsUwj9G" @@ -89,7 +87,6 @@ var _ = Describe("CustomMetrics Server", func() { Context("when a request to forward custom metrics comes without 'Basic'", func() { BeforeEach(func() { - rateLimiter.ExceedsLimitReturns(false) credentials = &models.Credential{} credentials.Username = "$2a$10$YnQNQYcvl/Q2BKtThOKFZ.KB0nTIZwhKr5q1pWTTwC/PUAHsbcpFu" credentials.Password = "$2a$10$6nZ73cm7IV26wxRnmm5E1.nbk9G.0a4MrbzBFPChkm5fPftsUwj9G" @@ -113,7 +110,6 @@ var _ = Describe("CustomMetrics Server", func() { Context("when a request to forward custom metrics comes with wrong user credentials", func() { BeforeEach(func() { - rateLimiter.ExceedsLimitReturns(false) credentials = &models.Credential{} credentials.Username = "$2a$10$YnQNQYcvl/Q2BKtThOKFZ.KB0nTIZwhKr5q1pWTTwC/PUAHsbcpFu" credentials.Password = "$2a$10$6nZ73cm7IV26wxRnmm5E1.nbk9G.0a4MrbzBFPChkm5fPftsUwj9G" @@ -138,7 +134,6 @@ var _ = Describe("CustomMetrics Server", func() { Context("when a request to forward custom metrics comes with unmatched metric types", func() { BeforeEach(func() { - rateLimiter.ExceedsLimitReturns(false) credentials = &models.Credential{} credentials.Username = "$2a$10$YnQNQYcvl/Q2BKtThOKFZ.KB0nTIZwhKr5q1pWTTwC/PUAHsbcpFu" credentials.Password = "$2a$10$6nZ73cm7IV26wxRnmm5E1.nbk9G.0a4MrbzBFPChkm5fPftsUwj9G" @@ -192,6 +187,9 @@ var _ = Describe("CustomMetrics Server", func() { resp, err = client.Do(req) Expect(err).NotTo(HaveOccurred()) }) + AfterEach(func() { + rateLimiter.ExceedsLimitReturns(false) + }) It("returns status code 429", func() { Expect(err).NotTo(HaveOccurred()) @@ -200,4 +198,4 @@ var _ = Describe("CustomMetrics Server", func() { }) }) -}) \ No newline at end of file +})