コード例 #1
0
    public void SetSubscriptionIamPolicy()
    {
        string topicId                  = "testTopicSetSubscriptionIamPolicy" + _pubsubFixture.RandomName();
        string subscriptionId           = "testSubscriptionSetSubscriptionIamPolicy" + _pubsubFixture.RandomName();
        string testRoleValueToConfirm   = "pubsub.editor";
        string testMemberValueToConfirm = "group:[email protected]";

        _pubsubFixture.CreateTopic(topicId);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        var policy = _setSubscriptionIamPolicySample.SetSubscriptionIamPolicy(_pubsubFixture.ProjectId, subscriptionId, testRoleValueToConfirm, testMemberValueToConfirm);

        Assert.Equal($"roles/{testRoleValueToConfirm}", policy.Bindings[0].Role);
        Assert.Contains(policy.Bindings[0].Members, c => c.Contains(testMemberValueToConfirm));
    }
コード例 #2
0
    public void SubscriptionPolicyPermisssions()
    {
        string topicId                  = "testTopicForTestSubscriptionIamPolicy" + _pubsubFixture.RandomName();
        string subscriptionId           = "testSubscriptionForTestSubscriptionIamPolicy" + _pubsubFixture.RandomName();
        string testRoleValueToConfirm   = "pubsub.editor";
        string testMemberValueToConfirm = "group:[email protected]";

        _pubsubFixture.CreateTopic(topicId);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        _setSubscriptionIamPolicySample.SetSubscriptionIamPolicy(_pubsubFixture.ProjectId, subscriptionId, testRoleValueToConfirm, testMemberValueToConfirm);

        var response = _testSubscriptionIamPermissionsSample.TestSubscriptionIamPermissionsResponse(_pubsubFixture.ProjectId, subscriptionId);

        Assert.NotEmpty(response.ToString());
    }