Search in sources :

Example 1 with RefreshTokenRequestStub

use of org.openhab.binding.netatmo.internal.authentication.RefreshTokenRequestStub in project openhab1-addons by openhab.

the class RefreshTokenTest method testSuccess.

@Test
public void testSuccess() throws Exception {
    final RefreshTokenRequestStub request = createRequest("/token.json");
    final RefreshTokenResponse response = request.execute();
    assertFalse(response.isError());
    assertNull(response.getError());
    assertEquals("grant_type=refresh_token&refresh_token=" + REFRESH_TOKEN + "&client_id=" + CLIENT_ID + "&client_secret=" + CLIENT_SECRET + "&scope=read_station read_camera", request.getContent());
    assertEquals("000000000000000000000000|11111111111111111111111111111111", response.getAccessToken());
}
Also used : RefreshTokenRequestStub(org.openhab.binding.netatmo.internal.authentication.RefreshTokenRequestStub) Test(org.junit.Test)

Example 2 with RefreshTokenRequestStub

use of org.openhab.binding.netatmo.internal.authentication.RefreshTokenRequestStub in project openhab1-addons by openhab.

the class RefreshTokenTest method testError.

@Test
public void testError() throws Exception {
    final RefreshTokenRequestStub request = createRequest("/error-2.json");
    final RefreshTokenResponse response = request.execute();
    assertTrue(response.isError());
    final NetatmoError error = response.getError();
    assertNotNull(error);
    assertEquals(2, error.getCode());
    assertEquals("Invalid access token", error.getMessage());
}
Also used : RefreshTokenRequestStub(org.openhab.binding.netatmo.internal.authentication.RefreshTokenRequestStub) NetatmoError(org.openhab.binding.netatmo.internal.messages.NetatmoError) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RefreshTokenRequestStub (org.openhab.binding.netatmo.internal.authentication.RefreshTokenRequestStub)2 NetatmoError (org.openhab.binding.netatmo.internal.messages.NetatmoError)1