return configuration.get(GROUP_NAME_ATTRIBUTE);
}
- boolean isEnabled() {
+ public boolean isEnabled() {
return configuration.getBoolean(ENABLED).orElse(false) &&
configuration.get(PROVIDER_ID).isPresent() &&
configuration.get(APPLICATION_ID).isPresent() &&
assertThat(remainingUser.getUserUuid()).isEqualTo(scimUserTestData2.userUuid);
}
+ @Test
+ public void deleteAll_should_remove_all_ScimUsers(){
+ insertScimUser("scimUser");
+ insertScimUser("scimUser2");
+
+ scimUserDao.deleteAll(dbSession);
+
+ assertThat(scimUserDao.findAll(dbSession)).isEmpty();
+ }
+
@Test
public void deleteFromUserUuid_shouldNotFail_whenNoUser() {
assertThatCode(() -> scimUserDao.deleteByUserUuid(dbSession, randomAlphanumeric(6))).doesNotThrowAnyException();
public String getManagedGroupSqlFilter(boolean filterByManaged) {
return String.format("%s exists (select group_uuid from scim_groups sg where sg.group_uuid = uuid)", filterByManaged ? "" : "not");
}
+
+ public void deleteAll(DbSession dbSession) {
+ mapper(dbSession).deleteAll();
+ }
}
void deleteByGroupUuid(@Param("groupUuid") String groupUuid);
void deleteByScimUuid(@Param("scimUuid") String scimUuid);
+
+ void deleteAll();
}
public String getManagedUserSqlFilter(boolean filterByManaged) {
return String.format("%s exists (select user_uuid from scim_users su where su.user_uuid = uuid)", filterByManaged ? "" : "not");
}
+
+ public void deleteAll(DbSession dbSession) {
+ mapper(dbSession).deleteAll();
+ }
}
void deleteByUserUuid(@Param("userUuid") String userUuid);
void deleteByScimUuid(@Param("scimUuid") String scimUuid);
+
+ void deleteAll();
}
delete from scim_groups where scim_uuid = #{scimUuid, jdbcType=VARCHAR}
</delete>
+ <update id="deleteAll">
+ delete from scim_groups
+ </update>
+
</mapper>
delete from scim_users where scim_uuid = #{scimUuid, jdbcType=VARCHAR}
</delete>
+ <update id="deleteAll">
+ delete from scim_users
+ </update>
+
</mapper>
assertThatCode(() -> scimGroupDao.deleteByGroupUuid(db.getSession(), randomAlphanumeric(6))).doesNotThrowAnyException();
}
+
+ @Test
+ public void deleteAll_should_remove_all_ScimGroups(){
+ insertScimGroup("scim-group-uuid1", "group-uuid1");
+ insertScimGroup("scim-group-uuid2", "group-uuid2");
+
+ scimGroupDao.deleteAll(db.getSession());
+
+ assertThat(scimGroupDao.findAll(db.getSession())).isEmpty();
+ }
}
}
private boolean isScimEnabled() {
- return this.configuration.getBoolean(SCIM_PROPERTY_ENABLED).orElse(false);
+ return this.internalProperties.read(SCIM_PROPERTY_ENABLED).map(Boolean::parseBoolean).orElse(false);
}
}
import com.tngtech.java.junit.dataprovider.UseDataProvider;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
+import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@Test
@UseDataProvider("getScimFeatureStatues")
- public void detect_scim_feature_status(boolean isEnabled) {
+ public void detect_scim_feature_status(String isEnabled) {
db.components().insertPublicProject();
- when(configuration.getBoolean(SCIM_PROPERTY_ENABLED)).thenReturn(Optional.of(isEnabled));
+ when(internalProperties.read(SCIM_PROPERTY_ENABLED)).thenReturn(Optional.ofNullable(isEnabled));
TelemetryData data = communityUnderTest.load();
- assertThat(data.isScimEnabled()).isEqualTo(isEnabled);
+ assertThat(data.isScimEnabled()).isEqualTo(Boolean.parseBoolean(isEnabled));
}
@Test
}
@DataProvider
- public static Set<Boolean> getScimFeatureStatues() {
- return Set.of(true, false);
+ public static Set<String> getScimFeatureStatues() {
+ HashSet<String> result = new HashSet<>();
+ result.add("true");
+ result.add("false");
+ result.add(null);
+ return result;
}
}