Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIM 8941 fix closed subscription check #11027

Open
wants to merge 1 commit into
base: 4.3.x
Choose a base branch
from

Conversation

mukul-tyagi08
Copy link
Contributor

Issue

https://gravitee.atlassian.net/browse/APIM-8941

Description

Closed subscription check when renewing api key. For UI we remove the button but for curl or direct request we need this check.

Additional context

@mukul-tyagi08 mukul-tyagi08 requested a review from a team as a code owner March 11, 2025 11:14
@mukul-tyagi08 mukul-tyagi08 force-pushed the APIM-8941-fix-closed-subscription-check branch 3 times, most recently from 594825b to 60ae7b2 Compare March 11, 2025 12:57
@mukul-tyagi08 mukul-tyagi08 requested a review from phiz71 March 11, 2025 13:14
@mukul-tyagi08 mukul-tyagi08 force-pushed the APIM-8941-fix-closed-subscription-check branch from 60ae7b2 to a819846 Compare March 11, 2025 19:41
Comment on lines +160 to +181
@Test
public void should_return_400_if_subscription_is_closed() {
final SubscriptionEntity subscriptionEntity = SubscriptionFixtures
.aSubscriptionEntity()
.toBuilder()
.id(SUBSCRIPTION)
.api("ANOTHER-API")
.status(SubscriptionStatus.CLOSED)
.build();

when(subscriptionService.findById(SUBSCRIPTION)).thenReturn(subscriptionEntity);

final Response response = rootTarget().request().post(Entity.json(SubscriptionFixtures.aRenewApiKey()));
assertEquals(BAD_REQUEST_400, response.getStatus());

var error = response.readEntity(Error.class);
assertEquals(BAD_REQUEST_400, (int) error.getHttpStatus());
assertEquals("Subscription [my-subscription] should be paused or accepted. Currently it is CLOSED", error.getMessage());

verify(subscriptionService, never()).pause(any(), any());
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to keep this test, you will have to mock apikeyservice so it returns an exception.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test here for the new exception?

@mukul-tyagi08 mukul-tyagi08 force-pushed the APIM-8941-fix-closed-subscription-check branch from a819846 to f4ee306 Compare March 12, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants