Ejemplo n.º 1
0
    public async Async.Task UserAuthorization_IsRequired(string method, RequestType authType)
    {
        var auth   = new TestEndpointAuthorization(authType, Logger, Context);
        var func   = new PoolFunction(Logger, auth, Context);
        var result = await func.Run(TestHttpRequestData.Empty(method));

        Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode);
    }
Ejemplo n.º 2
0
    public async Async.Task Search_SpecificPool_ByName_NotFound_ReturnsBadRequest()
    {
        var auth = new TestEndpointAuthorization(RequestType.User, Logger, Context);

        var req    = new PoolSearch(Name: _poolName);
        var func   = new PoolFunction(Logger, auth, Context);
        var result = await func.Run(TestHttpRequestData.FromJson("GET", req));

        Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode);
    }
Ejemplo n.º 3
0
    public async Async.Task Search_SpecificPool_ByState_NotFound_ReturnsEmptyResult()
    {
        var auth = new TestEndpointAuthorization(RequestType.User, Logger, Context);

        var req = new PoolSearch(State: new List <PoolState> {
            PoolState.Init
        });
        var func   = new PoolFunction(Logger, auth, Context);
        var result = await func.Run(TestHttpRequestData.FromJson("GET", req));

        Assert.Equal(HttpStatusCode.OK, result.StatusCode);

        Assert.Equal("[]", BodyAsString(result));
    }
Ejemplo n.º 4
0
    public async Async.Task Search_SpecificPool_ById_CanFind()
    {
        await Context.InsertAll(
            new Pool(_poolName, _poolId, Os.Linux, true, Architecture.x86_64, PoolState.Running, null));

        // queue must exist
        await Context.Queue.CreateQueue(Context.PoolOperations.GetPoolQueue(_poolId), StorageType.Corpus);

        // use test class to override instance ID
        Context.Containers = new TestContainers(Logger, Context.Storage, Context.Creds, Context.ServiceConfiguration);

        var auth = new TestEndpointAuthorization(RequestType.User, Logger, Context);

        var req    = new PoolSearch(PoolId: _poolId);
        var func   = new PoolFunction(Logger, auth, Context);
        var result = await func.Run(TestHttpRequestData.FromJson("GET", req));

        Assert.Equal(HttpStatusCode.OK, result.StatusCode);

        var pool = BodyAs <PoolGetResult>(result);

        Assert.Equal(_poolId, pool.PoolId);
    }