use of com.searchcode.app.dao.Api in project searchcode-server by boyter.
the class ApiServiceTest method testCase1.
public void testCase1() {
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", "e15db69d711f0f25ce07a9c11ebebe821e6fc312", "", ApiService.HmacType.SHA1);
assertTrue(actual);
}
use of com.searchcode.app.dao.Api in project searchcode-server by boyter.
the class App method preStart.
/**
* Called on startup to run all the DAO object table creation/migration logic. Slight overhead using this technique.
* TODO Do the migrations inside the sqlite database so the application does not need to
*/
public static void preStart() {
// Database migrations
Data data = Singleton.getData();
Repo repo = Singleton.getRepo();
Api api = Singleton.getApi();
data.createTableIfMissing();
api.createTableIfMissing();
repo.createTableIfMissing();
repo.addSourceToTable();
repo.addBranchToTable();
repo.addDataToTable();
}
use of com.searchcode.app.dao.Api in project searchcode-server by boyter.
the class AdminRouteService method adminApi.
public Map<String, Object> adminApi(Request request, Response response) {
Map<String, Object> map = new HashMap<>();
Api api = Singleton.getApi();
map.put("apiKeys", api.getAllApi());
boolean apiEnabled = Boolean.parseBoolean(Properties.getProperties().getProperty("api_enabled", "false"));
boolean apiAuth = Boolean.parseBoolean(Properties.getProperties().getProperty("api_key_authentication", "true"));
map.put("apiAuthentication", apiEnabled && apiAuth);
map.put("logoImage", CommonRouteService.getLogo());
map.put("isCommunity", App.ISCOMMUNITY);
map.put(Values.EMBED, Singleton.getData().getDataByName(Values.EMBED, Values.EMPTYSTRING));
map.put("repoCount", this.getStat("repoCount"));
return map;
}