use of com.searchcode.app.dao.Api in project searchcode-server by boyter.
the class ApiServiceTest method testValidateRequestCorrectHmacMethodSha1.
public void testValidateRequestCorrectHmacMethodSha1() {
Api apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(new ApiResult(1, "publicKey", "privateKey", "", ""));
ApiService service = new ApiService(apiMock);
boolean actual = service.validateRequest("publicKey", "3eb4cb7c8a30ac3814bbfae935cbe3c1f4f2acce", "stringtohmac", ApiService.HmacType.SHA1);
assertTrue(actual);
}
use of com.searchcode.app.dao.Api in project searchcode-server by boyter.
the class ApiServiceTest method testValidateRequestNoMatchingKeyExpectFalse.
public void testValidateRequestNoMatchingKeyExpectFalse() {
Api apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(null);
ApiService service = new ApiService(apiMock);
boolean actual = service.validateRequest("publicKey", "", "", ApiService.HmacType.SHA1);
assertFalse(actual);
}
use of com.searchcode.app.dao.Api in project searchcode-server by boyter.
the class ApiServiceTest method testValidateRequestInCorrectHmacMethodSha512.
public void testValidateRequestInCorrectHmacMethodSha512() {
Api apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(new ApiResult(1, "publicKey", "privateKey", "", ""));
ApiService service = new ApiService(apiMock);
boolean actual = service.validateRequest("publicKey", "thisiswrong", "stringtohmac", ApiService.HmacType.SHA512);
assertFalse(actual);
}
use of com.searchcode.app.dao.Api in project searchcode-server by boyter.
the class ApiServiceTest method testValidateRequestCorrectHmacMethodSha512.
public void testValidateRequestCorrectHmacMethodSha512() {
Api apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(new ApiResult(1, "publicKey", "privateKey", "", ""));
ApiService service = new ApiService(apiMock);
boolean actual = service.validateRequest("publicKey", "8d8219101eecb1ae62e025c79379872d7461cf201a737893afc172aa9c98c505c7d1f4d864d9adbc17f8e2694fb0287fb7533e942c34589fc2daefc068e0cad3", "stringtohmac", ApiService.HmacType.SHA512);
assertTrue(actual);
}
use of com.searchcode.app.dao.Api in project searchcode-server by boyter.
the class ApiServiceTest method testValidateRequestCorrectHmacMethod.
public void testValidateRequestCorrectHmacMethod() {
Api apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(new ApiResult(1, "publicKey", "privateKey", "", ""));
ApiService service = new ApiService(apiMock);
boolean actual = service.validateRequest("publicKey", "3eb4cb7c8a30ac3814bbfae935cbe3c1f4f2acce", "stringtohmac", ApiService.HmacType.SHA1);
assertTrue(actual);
}