Search in sources :

Example 11 with Api

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);
}
Also used : ApiResult(com.searchcode.app.model.ApiResult) Api(com.searchcode.app.dao.Api)

Example 12 with Api

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();
}
Also used : Repo(com.searchcode.app.dao.Repo) Data(com.searchcode.app.dao.Data) Api(com.searchcode.app.dao.Api)

Example 13 with Api

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;
}
Also used : Api(com.searchcode.app.dao.Api)

Aggregations

Api (com.searchcode.app.dao.Api)13 ApiResult (com.searchcode.app.model.ApiResult)10 Data (com.searchcode.app.dao.Data)1 Repo (com.searchcode.app.dao.Repo)1