Search in sources :

Example 1 with AuthenticatedUserDisplayInfo

use of edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo in project dataverse by IQSS.

the class GoogleOAuth2APTest method testParseUserResponseRealData.

@Test
public void testParseUserResponseRealData() {
    AbstractOAuth2AuthenticationProvider.ParsedUserResponse expResult = new AbstractOAuth2AuthenticationProvider.ParsedUserResponse(new AuthenticatedUserDisplayInfo("Philip", "Durbin", "philipdurbin@gmail.com", "", ""), null, null);
    AbstractOAuth2AuthenticationProvider.ParsedUserResponse result = parseUserResponse(GOOGLE_RESPONSE);
    assertEquals(expResult.displayInfo, result.displayInfo);
    assertEquals("107770072576338242009", result.userIdInProvider);
    assertEquals("philipdurbin", result.username);
    assertEquals("Philip", result.displayInfo.getFirstName());
    assertEquals("Durbin", result.displayInfo.getLastName());
    assertEquals("philipdurbin@gmail.com", result.displayInfo.getEmailAddress());
    assertEquals("", result.displayInfo.getPosition());
    assertEquals("", result.displayInfo.getAffiliation());
}
Also used : AbstractOAuth2AuthenticationProvider(edu.harvard.iq.dataverse.authorization.providers.oauth2.AbstractOAuth2AuthenticationProvider) AuthenticatedUserDisplayInfo(edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo) Test(org.junit.Test)

Example 2 with AuthenticatedUserDisplayInfo

use of edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo in project dataverse by IQSS.

the class BuiltinAuthenticationProviderTest method testUpdateUserInfo.

/**
 * Test of updateUserInfo method, of class BuiltinAuthenticationProvider.
 */
@Test
public void testUpdateUserInfo() {
    BuiltinUser user = bean.save(makeBuiltInUser());
    AuthenticatedUserDisplayInfo newInfo = new AuthenticatedUserDisplayInfo("nf", "nl", "ema@il.com", "newAffi", "newPos");
    sut.updateUserInfo(user.getUserName(), newInfo);
    assertEquals(newInfo, user.getDisplayInfo());
}
Also used : AuthenticatedUserDisplayInfo(edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo) Test(org.junit.Test)

Example 3 with AuthenticatedUserDisplayInfo

use of edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo in project dataverse by IQSS.

the class OrcidOAuth2APTest method testParseActivitiesResponseNoOrgName.

@Test
public void testParseActivitiesResponseNoOrgName() {
    OrcidOAuth2AP sut = new OrcidOAuth2AP("clientId", "clientSecret", "userEndpoint");
    assertNotNull(ACTIVITIES);
    String responseWithNoOrg = ACTIVITIES.replaceAll("\n", "").replaceAll("<employment:organization>.*</employment:organization>", "");
    final AuthenticatedUserDisplayInfo actual = sut.parseActivitiesResponse(responseWithNoOrg);
    assertEquals(null, actual.getAffiliation());
    assertEquals("role, department", actual.getPosition());
}
Also used : AuthenticatedUserDisplayInfo(edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo) Test(org.junit.Test)

Example 4 with AuthenticatedUserDisplayInfo

use of edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo in project dataverse by IQSS.

the class OrcidOAuth2APTest method testParseActivitiesResponse.

@Test
public void testParseActivitiesResponse() {
    OrcidOAuth2AP sut = new OrcidOAuth2AP("clientId", "clientSecret", "userEndpoint");
    assertNotNull(ACTIVITIES);
    final AuthenticatedUserDisplayInfo actual = sut.parseActivitiesResponse(ACTIVITIES);
    assertEquals("My Organization Name", actual.getAffiliation());
    assertEquals("role, department", actual.getPosition());
}
Also used : AuthenticatedUserDisplayInfo(edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo) Test(org.junit.Test)

Example 5 with AuthenticatedUserDisplayInfo

use of edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo in project dataverse by IQSS.

the class AuthenticatedUserTest method testGetDisplayInfo.

@Test
public void testGetDisplayInfo() {
    System.out.println("getDisplayInfo");
    AuthenticatedUserDisplayInfo expResult = new AuthenticatedUserDisplayInfo("Homer", "Simpson", "Homer.Simpson@someU.edu", "UnitTester", "In-Memory user");
    AuthenticatedUserDisplayInfo result = testUser.getDisplayInfo();
    assertEquals(expResult, result);
}
Also used : AuthenticatedUserDisplayInfo(edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo) Test(org.junit.Test)

Aggregations

AuthenticatedUserDisplayInfo (edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo)20 Test (org.junit.Test)8 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)5 StringReader (java.io.StringReader)4 BuiltinUser (edu.harvard.iq.dataverse.authorization.providers.builtin.BuiltinUser)3 IOException (java.io.IOException)3 Path (javax.ws.rs.Path)3 UserIdentifier (edu.harvard.iq.dataverse.authorization.UserIdentifier)2 AbstractOAuth2AuthenticationProvider (edu.harvard.iq.dataverse.authorization.providers.oauth2.AbstractOAuth2AuthenticationProvider)2 ShibUserNameFields (edu.harvard.iq.dataverse.authorization.providers.shib.ShibUserNameFields)2 JsonArrayBuilder (javax.json.JsonArrayBuilder)2 JsonObject (javax.json.JsonObject)2 JsonObjectBuilder (javax.json.JsonObjectBuilder)2 JsonReader (javax.json.JsonReader)2 PUT (javax.ws.rs.PUT)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 Document (org.w3c.dom.Document)2 Node (org.w3c.dom.Node)2