use of com.searchcode.app.util.Helpers in project searchcode-server by boyter.
the class ApiServiceTest method testValidateRequestCorrectHmacMethod.
public void testValidateRequestCorrectHmacMethod() {
var apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(Optional.of(new ApiResult(1, "publicKey", "privateKey", "", "")));
var service = new ApiService(apiMock, new Helpers());
var actual = service.validateRequest("publicKey", "3eb4cb7c8a30ac3814bbfae935cbe3c1f4f2acce", "stringtohmac", ApiService.HmacType.SHA1);
assertTrue(actual);
}
use of com.searchcode.app.util.Helpers in project searchcode-server by boyter.
the class ApiServiceTest method testValidateRequestCorrectHmac.
public void testValidateRequestCorrectHmac() {
var apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(Optional.of(new ApiResult(1, "publicKey", "privateKey", "", "")));
var service = new ApiService(apiMock, new Helpers());
var actual = service.validateRequest("publicKey", "3eb4cb7c8a30ac3814bbfae935cbe3c1f4f2acce", "stringtohmac", ApiService.HmacType.SHA1);
assertTrue(actual);
}
use of com.searchcode.app.util.Helpers in project searchcode-server by boyter.
the class ApiServiceTest method testValidateRequestCorrectHmacMethodSha1.
public void testValidateRequestCorrectHmacMethodSha1() {
var apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(Optional.of(new ApiResult(1, "publicKey", "privateKey", "", "")));
var service = new ApiService(apiMock, new Helpers());
var actual = service.validateRequest("publicKey", "3eb4cb7c8a30ac3814bbfae935cbe3c1f4f2acce", "stringtohmac", ApiService.HmacType.SHA1);
assertTrue(actual);
}
use of com.searchcode.app.util.Helpers in project searchcode-server by boyter.
the class ApiServiceTest method testValidateRequestInCorrectHmacMethodSha512.
public void testValidateRequestInCorrectHmacMethodSha512() {
var apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(Optional.of(new ApiResult(1, "publicKey", "privateKey", "", "")));
var service = new ApiService(apiMock, new Helpers());
var actual = service.validateRequest("publicKey", "thisiswrong", "stringtohmac", ApiService.HmacType.SHA512);
assertFalse(actual);
}
use of com.searchcode.app.util.Helpers in project searchcode-server by boyter.
the class ApiServiceTest method testCase3.
public void testCase3() {
var apiMock = mock(Api.class);
when(apiMock.getApiByPublicKey("publicKey")).thenReturn(Optional.of(new ApiResult(1, "publicKey", "privateKey", "", "")));
var service = new ApiService(apiMock, new Helpers());
var actual = service.validateRequest("publicKey", "0cb1ae7ab0db51dd82c4d29000523e643d8a1fcb", "?pub=publicKey&reponame=test&repourl=http://github.com/&reposource=&repobranch=master", ApiService.HmacType.SHA1);
assertTrue(actual);
}
Aggregations