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

Further Integration Tests for Alias Identity Providers Feature #2722

Conversation

adrianhoelzl-sap
Copy link
Contributor

see #2505

This PR adds additional MockMvc tests for some yet uncovered paths as well as for the GET IdPs endpoint.

@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/187017042

The labels on this github issue will be updated when the story is started.

Copy link
Contributor

@bruce-ricard bruce-ricard left a comment

Choose a reason for hiding this comment

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

It's hard to review as I don't know what code was moved (and git thinks it was deleted and rewritten), and which code is indeed new, and which one was deleted.

Do you think you could try to split it into multiple smaller commits?

@@ -327,85 +373,358 @@ protected UpdateBase(final boolean aliasFeatureEnabled) {
void setUp() {
arrangeAliasFeatureEnabled(aliasFeatureEnabled);
}
}

@Nested
Copy link
Contributor

Choose a reason for hiding this comment

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

This is confusing.

It looks like you didn't actually delete this, but that git is confused and believes so. It makes it harder to review. That's one of the many reasons I like smaller commits, it makes it easier on git and us.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this particular PR, it might be easier to just consider the new version of the test class and ignore the diffs git generated. The PDF I posted in the Slack channel might be helpful as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

But then I don't see what is being deleted. I can't validate that we are not removing test coverage.

The commit says that it adds further tests, but I see lots of lines of code being deleted.

@Tallicia
Copy link
Contributor

As discussed in last week's sync up, @adrianhoelzl-sap when you have updated the commits for this, I'll review as @bruce-ricard is out this week.

@adrianhoelzl-sap adrianhoelzl-sap force-pushed the feature/alias-id-and-alias-zid-for-identity-providers-further-integration-tests branch from be1add2 to 115bad4 Compare March 19, 2024 12:27
@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/187268528

The labels on this github issue will be updated when the story is started.

@adrianhoelzl-sap adrianhoelzl-sap marked this pull request as draft March 19, 2024 12:33
@adrianhoelzl-sap
Copy link
Contributor Author

As discussed in last week's sync up, @adrianhoelzl-sap when you have updated the commits for this, I'll review as @bruce-ricard is out this week.

Thanks for the update. I'll convert this PR back from draft to regular once it is ready for review.

…ias and the aliasId is set in the update payload (valid for enabled and disabled alias feature)
…e to alias in existing IdP if alias feature is disabled
…xists and the update payload contains a non-empty aliasZid
…iesChangedWhileAliasPropertiesUnchanged to nested class ExistingAlias
…PropertiesToNull to nested class ExistingAlias
…ertiesToNullAndChangeOtherProperties to nested class ExistingAlias
…AliasIdOfExistingIdpMissing to nested class ExistingAlias
…DanglingReference to nested class ExistingAlias
@Test
void shouldReject_AliasIdNotSetInPayload_CustomToUaaZone() throws Exception {
shouldReject_AliasIdNotSetInPayload(customZone, IdentityZone.getUaa());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

@Test
void shouldReject_AliasIdNotSetInPayload_UaaToCustomZone() throws Exception {
shouldReject_AliasIdNotSetInPayload(IdentityZone.getUaa(), customZone);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

@Test
void shouldAccept_OtherPropertiesOfIdpWithAliasAreChanged_CustomToUaaZone() throws Exception {
shouldAccept_OtherPropertiesOfIdpWithAliasAreChanged(customZone, IdentityZone.getUaa());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

class ExistingAlias {
@Test
void shouldAccept_OtherPropertiesOfIdpWithAliasAreChanged_UaaToCustomZone() throws Exception {
shouldAccept_OtherPropertiesOfIdpWithAliasAreChanged(IdentityZone.getUaa(), customZone);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

);
idp.setAliasZid(zone.getId());
shouldRejectUpdate(zone, idp, HttpStatus.UNPROCESSABLE_ENTITY);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

@Test
void shouldReject_AliasZidSetToSameZone_CustomZone() throws Exception {
shouldReject_AliasZidSetToSameZone(customZone);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

@Test
void shouldReject_AliasZidSetToSameZone_UaaZone() throws Exception {
shouldReject_AliasZidSetToSameZone(IdentityZone.getUaa());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

// try to create an alias for the IdP -> should fail because of the IdP's type
createdProvider.setAliasZid(zone2.getId());
shouldRejectUpdate(zone1, createdProvider, HttpStatus.UNPROCESSABLE_ENTITY);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

private void shouldReject_AliasNotSupportedForIdpType(final IdentityZone zone1, final IdentityZone zone2) throws Exception {
final IdentityProvider<?> uaaIdp = buildUaaIdpWithAliasProperties(zone1.getId(), null, null);
final IdentityProvider<?> createdProvider = createIdp(zone1, uaaIdp);
assertThat(createdProvider.getAliasZid()).isBlank();
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

@Test
void shouldReject_AliasNotSupportedForIdpType_CustomZone() throws Exception {
shouldReject_AliasNotSupportedForIdpType(customZone, IdentityZone.getUaa());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

@Test
void shouldReject_AliasNotSupportedForIdpType_UaaToCustomZone() throws Exception {
shouldReject_AliasNotSupportedForIdpType(IdentityZone.getUaa(), customZone);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.


// the alias IdP should have its reference removed
assertReferenceWasRemovedFromAlias(initialAliasId, initialAliasZid);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

@Test
void shouldAccept_SetOnlyAliasPropertiesToNull_UaaToCustomZone() throws Throwable {
shouldAccept_SetOnlyAliasPropertiesToNull(IdentityZone.getUaa(), customZone);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

existingIdp.setAliasId(null);
existingIdp.setAliasZid(null);
existingIdp.setName("some-new-name");
shouldRejectUpdate(zone1, existingIdp, HttpStatus.UNPROCESSABLE_ENTITY);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.


// check if the returned IdP has a redacted relying party secret
assertRelyingPartySecretIsRedacted(updatedIdp);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

final String newAliasId,
final String newAliasZid
) throws Throwable {
shouldReject_ChangingAliasPropertiesOfIdpWithAlias(newAliasId, newAliasZid, IdentityZone.getUaa(), customZone);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

final String newAliasId,
final String newAliasZid
) throws Throwable {
shouldReject_ChangingAliasPropertiesOfIdpWithAlias(newAliasId, newAliasZid, customZone, IdentityZone.getUaa());
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

);
@Test
void shouldReject_OnlyAliasZidSetToNull_UaaToCustomZone() throws Throwable {
shouldReject_OnlyAliasZidSetToNull(IdentityZone.getUaa(), customZone);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

assertThat(originalIdp.getAliasZid()).isNotBlank();
@Test
void shouldReject_OnlyAliasZidSetToNull_CustomToUaaZone() throws Throwable {
shouldReject_OnlyAliasZidSetToNull(customZone, IdentityZone.getUaa());
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

shouldReject_OnlyAliasZidSetToNull(customZone, IdentityZone.getUaa());
}
originalIdp.setAliasId(null);
shouldRejectUpdate(zone1, originalIdp, HttpStatus.UNPROCESSABLE_ENTITY);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

shouldReject_OnlyAliasZidSetToNull(IdentityZone.getUaa(), customZone);
}
assertThat(originalIdp.getAliasId()).isNotBlank();
assertThat(originalIdp.getAliasZid()).isNotBlank();
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

private IdentityProvider<?> updateIdpViaDb(final String zoneId, final IdentityProvider<?> idp) {
final JdbcIdentityProviderProvisioning identityProviderProvisioning = webApplicationContext
.getBean(JdbcIdentityProviderProvisioning.class);
return identityProviderProvisioning.update(idp, zoneId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

assertThat(originalIdp.getAliasZid()).isNotBlank();

originalIdp.setAliasZid(null);
shouldRejectUpdate(zone1, originalIdp, HttpStatus.UNPROCESSABLE_ENTITY);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Leaving comments to track my progress as this is challenging to read through.

Copy link
Contributor

@Tallicia Tallicia left a comment

Choose a reason for hiding this comment

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

I believe I have covered all the changes, but they are very difficult to read through. I would highly suggest keeping PRs separated between Added New tests and Updating/Refactoring existing tests.

@Tallicia Tallicia added the accepted Accepted the issue label Mar 27, 2024
@adrianhoelzl-sap adrianhoelzl-sap merged commit d6b85bc into develop Mar 28, 2024
20 checks passed
@adrianhoelzl-sap adrianhoelzl-sap deleted the feature/alias-id-and-alias-zid-for-identity-providers-further-integration-tests branch March 28, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants