@Override
 protected void afterSetup() throws IOException {
   fileSystem.delete(etc, true);
   fileSystem.mkdirs(etc);
   PolicyFiles.copyToDir(
       fileSystem, etc, "test-authz-provider.ini", "test-authz-provider-other-group.ini");
   setPolicy(
       new DBPolicyFileBackend(new Path(etc, "test-authz-provider.ini").toString(), "server1"));
 }
 @Override
 protected void afterSetup() throws IOException {
   File baseDir = getBaseDir();
   Assert.assertNotNull(baseDir);
   Assert.assertTrue(baseDir.isDirectory() || baseDir.mkdirs());
   PolicyFiles.copyToDir(baseDir, "test-authz-provider.ini");
   setPolicy(
       new SqoopPolicyFileProviderBackend(
           sqoopServerName, new File(baseDir, "test-authz-provider.ini").getPath()));
 }
  @Test
  public void testMultiFSPolicy() throws Exception {
    File globalPolicyFile = new File(Files.createTempDir(), "global-policy.ini");
    File dbPolicyFile = new File(Files.createTempDir(), "db11-policy.ini");

    // Create global policy file
    PolicyFile dbPolicy =
        new PolicyFile()
            .addPermissionsToRole("db11_role", "server=server1->db=db11")
            .addRolesToGroup("group1", "db11_role");

    dbPolicy.write(dbPolicyFile);
    Path dbPolicyPath = new Path(etc, "db11-policy.ini");

    // create per-db policy file
    PolicyFile globalPolicy =
        new PolicyFile()
            .addPermissionsToRole("admin_role", "server=server1")
            .addRolesToGroup("admin_group", "admin_role")
            .addGroupsToUser("db", "admin_group");
    globalPolicy.addDatabase("db11", dbPolicyPath.toUri().toString());
    globalPolicy.write(globalPolicyFile);

    PolicyFiles.copyFilesToDir(fileSystem, etc, globalPolicyFile);
    PolicyFiles.copyFilesToDir(fileSystem, etc, dbPolicyFile);
    DBPolicyFileBackend multiFSEngine =
        new DBPolicyFileBackend(globalPolicyFile.getPath(), "server1");

    List<Authorizable> dbAuthorizables = Lists.newArrayList();
    dbAuthorizables.add(new Server("server1"));
    dbAuthorizables.add(new Database("db11"));
    List<String> dbGroups = Lists.newArrayList();
    dbGroups.add("group1");
    ImmutableSetMultimap<String, String> dbPerms =
        multiFSEngine.getPermissions(dbAuthorizables, dbGroups);
    Assert.assertEquals("No DB permissions found", 1, dbPerms.size());
  }