use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Identity in project linuxtools by eclipse.
the class TestOSIORestGetAuthUser method testGetAuthUser.
@Test
public void testGetAuthUser() throws Exception {
TestData testData = new TestData();
TestUtils.initSpaces(requestProvider, testData);
OSIORestClient client = connector.getClient(repository, requestProvider);
OSIORestConfiguration config = client.getConfiguration(repository, new NullOperationMonitor());
config.setSpaces(testData.spaceMap);
connector.setConfiguration(config);
RepositoryLocation location = client.getClient().getLocation();
location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
OSIORestGetAuthUser data = new OSIORestGetAuthUser(client.getClient());
String bundleLocation = Activator.getContext().getBundle().getLocation();
int index = bundleLocation.indexOf('/');
String fileName = bundleLocation.substring(index) + "/testjson/authuser.data";
FileReader in = new FileReader(fileName);
Identity user = data.testParseFromJson(in);
assertEquals("User.org", user.getCompany());
assertEquals("user@user.org", user.getEmail());
assertEquals("User 1", user.getFullName());
assertEquals("IDENTITY-0001", user.getIdentityID());
assertEquals("https://www.gravatar.com/avatar/user.jpg", user.getImageURL());
assertEquals("USER-0001", user.getUserID());
assertEquals("user", user.getUsername());
assertEquals("IDENTITY-0001", user.getId());
}
use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Identity in project linuxtools by eclipse.
the class OSIORestClient method validate.
public boolean validate(IOperationMonitor monitor) throws OSIORestException {
RepositoryLocation location = getClient().getLocation();
if (location.getProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN) != null) {
// UserCredentials credentials = location.getCredentials(AuthenticationType.REPOSITORY);
// Preconditions.checkState(credentials != null, "Authentication requested without valid credentials");
String userName = location.getProperty(IOSIORestConstants.REPOSITORY_AUTH_ID);
Identity response = restRequestProvider.getAuthUser(monitor, client);
if (response.getUsername().equals(userName)) {
return true;
}
}
return false;
}
use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Identity in project linuxtools by eclipse.
the class TestOSIORestClient method setUp.
@SuppressWarnings("deprecation")
@Before
public void setUp() {
connector = new OSIORestConnector();
repository = new TaskRepository(connector.getConnectorKind(), "http://openshift.io/api");
repository.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
repository.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
requestProvider = new OSIOTestRestRequestProvider();
requestProvider.addGetRequest("/user", new Identity("user", "user", new Date(2017, 01, 01), new Date(2017, 01, 01), "User", "//image/user", "user", Boolean.TRUE, "user@user.org", "userCo", "", "//users/user", "TestUser"));
}
use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Identity in project linuxtools by eclipse.
the class TestOSIORestGetUser method testGetUser.
@Test
public void testGetUser() throws Exception {
TestData testData = new TestData();
TestUtils.initSpaces(requestProvider, testData);
OSIORestClient client = connector.getClient(repository, requestProvider);
OSIORestConfiguration config = client.getConfiguration(repository, new NullOperationMonitor());
config.setSpaces(testData.spaceMap);
connector.setConfiguration(config);
RepositoryLocation location = client.getClient().getLocation();
location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
OSIORestGetUser data = new OSIORestGetUser(client.getClient(), "USER-0001");
String bundleLocation = Activator.getContext().getBundle().getLocation();
int index = bundleLocation.indexOf('/');
String fileName = bundleLocation.substring(index) + "/testjson/user.data";
FileReader in = new FileReader(fileName);
Identity user = data.testParseFromJson(in);
assertEquals("User.org", user.getCompany());
assertEquals("user@user.org", user.getEmail());
assertEquals("User 1", user.getFullName());
assertEquals("IDENTITY-0001", user.getIdentityID());
assertEquals("https://www.gravatar.com/avatar/user.jpg", user.getImageURL());
assertEquals("USER-0001", user.getUserID());
assertEquals("user", user.getUsername());
assertEquals("IDENTITY-0001", user.getId());
}
Aggregations