Exemplo n.º 1
0
 @Test
 public void testCreate_Enabled()
     throws ServiceNotEnabledException, ServiceNotAuthorizedException {
   db.getConfig().setBoolean("http", null, "getanyfile", true);
   service.access(new R(null, "1.2.3.4"), db);
   service.access(new R("bob", "1.2.3.4"), db);
 }
Exemplo n.º 2
0
  @Test
  public void testDisabledSingleton() throws ServiceNotAuthorizedException {
    service = AsIsFileService.DISABLED;
    try {
      service.access(new R(null, "1.2.3.4"), db);
      fail("Created session for anonymous user: null");
    } catch (ServiceNotEnabledException e) {
      // expected not authorized
    }

    try {
      service.access(new R("bob", "1.2.3.4"), db);
      fail("Created session for user: \"bob\"");
    } catch (ServiceNotEnabledException e) {
      // expected not authorized
    }
  }
Exemplo n.º 3
0
  @Test
  public void testCreate_Disabled() throws ServiceNotAuthorizedException, IOException {
    final StoredConfig cfg = db.getConfig();
    cfg.setBoolean("http", null, "getanyfile", false);
    cfg.save();

    try {
      service.access(new R(null, "1.2.3.4"), db);
      fail("Created session for anonymous user: null");
    } catch (ServiceNotEnabledException e) {
      // expected not authorized
    }

    try {
      service.access(new R("bob", "1.2.3.4"), db);
      fail("Created session for user: \"bob\"");
    } catch (ServiceNotEnabledException e) {
      // expected not authorized
    }
  }
Exemplo n.º 4
0
 @Test
 public void testCreate_Default()
     throws ServiceNotEnabledException, ServiceNotAuthorizedException {
   service.access(new R(null, "1.2.3.4"), db);
   service.access(new R("bob", "1.2.3.4"), db);
 }