Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-1096

Explicitly handle auth error for observe with xerror

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 2.5.0, 2.4.8
    • 2.4.7
    • None
    • None
    • 5.0.0-3317

    Description

      test https://github.com/couchbaselabs/sdk-qe/blob/RBAC_java/functional-tests/java-functional/src/main/java/com/couchbase/sdkqe/test/functional/FunctionalRBACTest.java#L689-L706

      steps: 

      create user DataRolesDataWriterAllBuckets  with role data_writer[*] and try to create doc like:

       

       
      String key = username + "_doc";
      JsonObject content = JsonObject.create().put("hello", "world");
      if (writeAccess != null && !writeAccess) {
          assertTrue(addKey(key, content, GAMESIM_SAMPLE_BUCKET, HOST));
      }
       
      if (createUser) {
          UserRole[] roles = {new UserRole(userRole, bucketName)};
          assertTrue(createUser("DataRolesDataWriterAllBuckets", "data_writer[*]", "password", HOST));
          Thread.sleep(10000);
      }
       
      CouchbaseCluster cluster = CouchbaseCluster.create(HOST);
      cluster.authenticate(username, password);
       
      Bucket bucket = null;
       
      try {
          bucket = cluster.openBucket(GAMESIM_SAMPLE_BUCKET);
          assertTrue("User '" + username + "' with role '" + userRole + "' can open bucket '" + GAMESIM_SAMPLE_BUCKET + "' but shouldn't!", openBucketAccess);
      } catch (Exception ex) {
          assertFalse("User '" + username + "' with role '" + userRole + "' can't open bucket '" + GAMESIM_SAMPLE_BUCKET + "' but should! " + ex, openBucketAccess);
          return;
      }
       
      try {
          JsonDocument upsert_result = bucket.upsert(JsonDocument.create(key, content), PersistTo.ONE, ReplicateTo.ONE, TIMEOUT, TimeUnit.SECONDS);
          assertTrue("User '" + username + "' with role '" + userRole + "' has write access but shouldn't! " + upsert_result, writeAccess);
      } catch (Exception ex) {
          assertFalse("User '" + username + "' with role '" + userRole + "' doesn't have write access but should! " + ex, writeAccess);  -FAILED
      }

      Attachments

        1. JCBC-1096
          687 kB
          Andrei Baranouski
        2. Screen Shot 2017-07-21 at 11.23.12.png
          333 kB
          Andrei Baranouski
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            daschl Michael Nitschinger
            andreibaranouski Andrei Baranouski
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty