Skip to content

Commit

Permalink
Convert ORCID OAuth2 provider test from JUnit4 to JUnit5. IQSS#7025
Browse files Browse the repository at this point in the history
  • Loading branch information
poikilotherm committed Jul 8, 2020
1 parent 0e75d27 commit fc9e633
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import edu.harvard.iq.dataverse.authorization.providers.oauth2.AbstractOAuth2AuthenticationProvider;
import edu.harvard.iq.dataverse.authorization.providers.oauth2.OAuth2Exception;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

/**
*
Expand Down Expand Up @@ -82,14 +82,14 @@ public void testExtractOrcid() throws OAuth2Exception {
assertEquals("0000-0001-2345-6789", sut.extractOrcidNumber(response));
}

@Test( expected=OAuth2Exception.class )
@Test
public void testExtractOrcidBad() throws OAuth2Exception {
// sample response from https://members.orcid.org/api/tutorial/read-orcid-records
String response = "{\"access_token\":\"f5af9f51-07e6-4332-8f1a-c0c11c1e3728\",\"token_type\":\"bearer\",\n" +
"\"refresh_token\":\"f725f747-3a65-49f6-a231-3e8944ce464d\",\"expires_in\":631138518,\n" +
"\"scope\":\"/read-limited\",\"name\":\"Sofia Garcia\"}";
OrcidOAuth2AP sut = new OrcidOAuth2AP("clientId", "clientSecret", "userEndpoint");
sut.extractOrcidNumber(response);
assertThrows(OAuth2Exception.class, () -> sut.extractOrcidNumber(response));
}

@Test
Expand Down

0 comments on commit fc9e633

Please sign in to comment.