Skip to content

Commit

Permalink
Remove other togglz
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Dec 12, 2023
1 parent a3f37fd commit 25212bc
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Objects;
import java.util.Set;

import org.orcid.core.togglz.Features;
import org.springframework.security.oauth2.common.exceptions.InvalidGrantException;
import org.springframework.security.oauth2.common.exceptions.InvalidRequestException;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
Expand Down Expand Up @@ -92,10 +91,6 @@ private boolean isEqual(String str1, String str2) {

@Override
protected boolean hostMatches(String registered, String requested) {
// If we should allow subdomains
if (!Features.DISABLE_MATCHING_SUBDOMAINS.isActive()) {
return isEqual(registered, requested) || (requested != null && requested.endsWith("." + registered));
}
return isEqual(registered, requested);
return isEqual(registered, requested) || (requested != null && requested.endsWith("." + registered));
}
}
28 changes: 0 additions & 28 deletions orcid-core/src/main/java/org/orcid/core/togglz/Features.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,9 @@ public enum Features implements Feature {
@Label("Move client from a member to another member")
MOVE_CLIENT,

@Label("Add other people contributions via BIBTEXT")
ADD_OTHER_WORK_CONTRIBUTORS_WITH_BIBTEX,

@Label("Disable matching subdomains")
DISABLE_MATCHING_SUBDOMAINS,

@Label("Enable Crazy Egg")
CRAZY_EGG,

@Label("Add other people contributions via DOI & PUBMED")
ADD_OTHER_WORK_CONTRIBUTORS_WITH_DOI_PUBMED,

@Label("Add other people contributions manually")
ADD_OTHER_WORK_CONTRIBUTORS,

@Label("Restrict delegator access to account settings")
RESTRICTED_DELEGATORS,

Expand All @@ -56,25 +44,12 @@ public enum Features implements Feature {

@Label("Spam button")
SPAM_BUTTON,

@Label("Email status dropdown option")
EMAIL_STATUS_DROPDOWN_OPTION,

@Label("Enable 2019 header")
ENABLE_HEADER2,

@Label("Change view privacy from work/funding/affiliation form dialogs")
DIALOG_PRIVACY_OPTION,

@Label("Shows an alert message when a user goes to /signin and is already signed in\n")
RE_LOGGIN_ALERT,

@Label("Affiliation org ID in UI")
AFFILIATION_ORG_ID,

@Label("Affiliation search")
AFFILIATION_SEARCH,

@Label("Arabic translation")
LANG_AR,

Expand All @@ -96,9 +71,6 @@ public enum Features implements Feature {
@Label("Self service org ids")
SELF_SERVICE_ORG_IDS,

@Label("Disable reCAPTCHA")
DISABLE_RECAPTCHA,

@Label("Check external id resolution in UI")
EX_ID_RESOLVER,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.orcid.core.exception.UnexpectedResponseCodeException;
import org.orcid.core.locale.LocaleManager;
import org.orcid.core.manager.IdentifierTypeManager;
import org.orcid.core.togglz.Features;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.core.utils.v3.identifiers.PIDNormalizationService;
import org.orcid.core.utils.v3.identifiers.PIDResolverCache;
import org.orcid.core.utils.v3.identifiers.normalizers.DOINormalizer;
Expand All @@ -41,14 +41,12 @@
import org.orcid.jaxb.model.v3.release.record.Citation;
import org.orcid.jaxb.model.v3.release.record.ExternalID;
import org.orcid.jaxb.model.v3.release.record.ExternalIDs;
import org.orcid.jaxb.model.v3.release.record.Work;
import org.orcid.jaxb.model.v3.release.record.WorkTitle;
import org.orcid.pojo.ContributorsRolesAndSequences;
import org.orcid.pojo.IdentifierType;
import org.orcid.pojo.PIDResolutionResult;
import org.orcid.pojo.WorkExtended;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.core.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -345,7 +343,7 @@ private WorkExtended getWorkExtended(JSONObject json) throws JSONException {
} catch (JSONException ignored) { }
}

if (json.has("author") && Features.ADD_OTHER_WORK_CONTRIBUTORS_WITH_DOI_PUBMED.isActive() ) {
if (json.has("author")) {
List<ContributorsRolesAndSequences> contributorsGroupedByOrcid = new ArrayList<>();
try {
JSONArray contributors = json.getJSONArray("author");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
import org.orcid.core.exception.UnexpectedResponseCodeException;
import org.orcid.core.locale.LocaleManager;
import org.orcid.core.manager.IdentifierTypeManager;
import org.orcid.core.togglz.Features;
import org.orcid.core.utils.v3.identifiers.PIDNormalizationService;
import org.orcid.core.utils.v3.identifiers.PIDResolverCache;
import org.orcid.jaxb.model.common.Relationship;
import org.orcid.jaxb.model.common.SequenceType;
import org.orcid.jaxb.model.common.WorkType;
import org.orcid.jaxb.model.v3.release.common.ContributorAttributes;
import org.orcid.jaxb.model.v3.release.common.ContributorOrcid;
Expand Down Expand Up @@ -242,7 +240,7 @@ private WorkExtended getWork(JSONObject json) throws JSONException, ParseExcepti
addExternalIdentifier(work, "doi", workMetadata.getString("doi"), locale);
}

if (workMetadata.has("authorList") && Features.ADD_OTHER_WORK_CONTRIBUTORS_WITH_DOI_PUBMED.isActive()) {
if (workMetadata.has("authorList")) {
List<ContributorsRolesAndSequences> contributorsGroupedByOrcid = new ArrayList<>();
JSONObject authorList = workMetadata.getJSONObject("authorList");
JSONArray contributors = authorList.getJSONArray("author");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,10 @@ public void resolveRedirectTest() {

@Test
public void redirectUriGeneralTests() {
redirectUriGeneralTest(true);
redirectUriGeneralTest(false);
redirectUriGeneralTest();
}

private void redirectUriGeneralTest(Boolean togglzEnabled) {
if(togglzEnabled) {
togglzRule.enable(Features.DISABLE_MATCHING_SUBDOMAINS);
} else {
togglzRule.disable(Features.DISABLE_MATCHING_SUBDOMAINS);
}

private void redirectUriGeneralTest() {
// No matches at all
assertFalse(resolver.redirectMatches("https://example.com", "https://qa.orcid.org"));
assertFalse(resolver.redirectMatches("https://qa.orcid.org", "https://example.com"));
Expand Down Expand Up @@ -225,9 +218,6 @@ private void redirectUriGeneralTest(Boolean togglzEnabled) {

@Test
public void redirectMatches_AllowMatchingSubdomainsTest() {
// Allow matching subdomains
togglzRule.disable(Features.DISABLE_MATCHING_SUBDOMAINS);

// Temp: Subdomain should match if the togglz is OFF
assertTrue(resolver.redirectMatches("https://www.orcid.org", "https://orcid.org"));
assertTrue(resolver.redirectMatches("https://qa.orcid.org", "https://orcid.org"));
Expand All @@ -238,18 +228,4 @@ public void redirectMatches_AllowMatchingSubdomainsTest() {
assertTrue(resolver.redirectMatches("https://www.example.com", "https://example.com"));
}

@Test
public void redirectMatches_RejectMatchingSubdomainsTest() {
// Reject matching subdomains
togglzRule.enable(Features.DISABLE_MATCHING_SUBDOMAINS);

// Subdomain should not match if togglz is ON
assertFalse(resolver.redirectMatches("https://www.orcid.org", "https://orcid.org"));
assertFalse(resolver.redirectMatches("https://qa.orcid.org", "https://orcid.org"));

// Acceptance criteria checks: subdomains should be rejected
assertFalse(resolver.redirectMatches("https://subdomain.example.com/", "https://example.com"));
assertFalse(resolver.redirectMatches("https://subdomain.example.com/subdirectory", "https://example.com"));
assertFalse(resolver.redirectMatches("https://www.example.com", "https://example.com"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;

Expand All @@ -14,6 +14,7 @@
import java.util.Locale;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
Expand All @@ -22,6 +23,7 @@
import org.mockito.stubbing.Answer;
import org.orcid.core.locale.LocaleManager;
import org.orcid.core.manager.IdentifierTypeManager;
import org.orcid.core.togglz.Features;
import org.orcid.core.utils.v3.identifiers.PIDNormalizationService;
import org.orcid.core.utils.v3.identifiers.PIDResolverCache;
import org.orcid.core.utils.v3.identifiers.resolvers.DOIResolver;
Expand All @@ -34,9 +36,7 @@
import org.orcid.pojo.WorkExtended;
import org.orcid.test.TargetProxyHelper;
import org.springframework.test.util.ReflectionTestUtils;
import org.orcid.core.togglz.Features;
import org.togglz.junit.TogglzRule;
import org.junit.Rule;



Expand Down Expand Up @@ -195,7 +195,6 @@ public InputStream answer(InvocationOnMock invocation) throws Throwable {

});

togglzRule.enable(Features.ADD_OTHER_WORK_CONTRIBUTORS_WITH_DOI_PUBMED);
when(cache.get(eq("https://doi.org/10.000/0000.0004"), any(HashMap.class))).thenAnswer(new Answer<InputStream>() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javax.ws.rs.core.MediaType;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
Expand All @@ -22,6 +23,7 @@
import org.mockito.stubbing.Answer;
import org.orcid.core.locale.LocaleManager;
import org.orcid.core.manager.IdentifierTypeManager;
import org.orcid.core.togglz.Features;
import org.orcid.core.utils.v3.identifiers.PIDNormalizationService;
import org.orcid.core.utils.v3.identifiers.PIDResolverCache;
import org.orcid.core.utils.v3.identifiers.resolvers.PubMedResolver;
Expand All @@ -34,8 +36,6 @@
import org.orcid.test.TargetProxyHelper;
import org.springframework.test.util.ReflectionTestUtils;
import org.togglz.junit.TogglzRule;
import org.junit.Rule;
import org.orcid.core.togglz.Features;


public class PubMedResolverTest {
Expand Down Expand Up @@ -226,7 +226,6 @@ public void resolvePMIDMetadataTest() {

@Test
public void resolvePMIDMetadataContributorsTest() {
togglzRule.enable(Features.ADD_OTHER_WORK_CONTRIBUTORS_WITH_DOI_PUBMED);
WorkExtended work = resolver.resolveMetadata("pmid", "pmid1");
List<ContributorsRolesAndSequences> contributors = work.getContributorsGroupedByOrcid();
assertNotNull(work);
Expand Down

0 comments on commit 25212bc

Please sign in to comment.