Exemplo n.º 1
0
    public void TestCreateHmacKey()
    {
        CreateHmacKeySample createHmacKeySample = new CreateHmacKeySample();
        string serviceAccountEmail = _bucketFixture.GetServiceAccountEmail();

        // Create key.
        var key = createHmacKeySample.CreateHmacKey(_bucketFixture.ProjectId, serviceAccountEmail);

        Assert.Equal(key.Metadata.ServiceAccountEmail, serviceAccountEmail);

        // Delete key.
        _bucketFixture.DeleteHmacKey(key.Metadata.AccessId);
    }
    public void TestListHmacKeys()
    {
        CreateHmacKeySample createHmacKeySample = new CreateHmacKeySample();
        ListHmacKeysSample  listHmacKeysSample  = new ListHmacKeysSample();

        string serviceAccountEmail = _bucketFixture.GetServiceAccountEmail();

        // Create key.
        var key = createHmacKeySample.CreateHmacKey(_bucketFixture.ProjectId, serviceAccountEmail);

        // List keys.
        var keys = listHmacKeysSample.ListHmacKeys(_bucketFixture.ProjectId);

        Assert.Contains(keys, key => key.AccessId == key.AccessId);

        // Delete key.
        _bucketFixture.DeleteHmacKey(key.Metadata.AccessId);
    }
    public void TestDeactivateHmacKey()
    {
        CreateHmacKeySample     createHmacKeySample     = new CreateHmacKeySample();
        DeactivateHmacKeySample deactivateHmacKeySample = new DeactivateHmacKeySample();
        DeleteHmacKeySample     deleteHmacKeySample     = new DeleteHmacKeySample();

        string serviceAccountEmail = _bucketFixture.GetServiceAccountEmail();

        // Create key.
        var key = createHmacKeySample.CreateHmacKey(_bucketFixture.ProjectId, serviceAccountEmail);

        // Deactivate key.
        var keyMetadata = deactivateHmacKeySample.DeactivateHmacKey(_bucketFixture.ProjectId, key.Metadata.AccessId);

        Assert.Equal("INACTIVE", keyMetadata.State);

        // Delete key.
        deleteHmacKeySample.DeleteHmacKey(_bucketFixture.ProjectId, key.Metadata.AccessId);
    }