Search in sources :

Example 1 with RangerHdfsAuthorizer

use of org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer in project ranger by apache.

the class RangerHdfsAuthorizerTest method setup.

@BeforeClass
public static void setup() {
    try {
        File file = File.createTempFile("hdfs-version-site", ".xml");
        file.deleteOnExit();
        try (final FileOutputStream outStream = new FileOutputStream(file);
            final OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8)) {
            writer.write("<configuration>\n" + "        <property>\n" + "                <name>hdfs.version</name>\n" + "                <value>hdfs_version_3.0</value>\n" + "        </property>\n" + "</configuration>\n");
        }
        RangerConfiguration config = RangerConfiguration.getInstance();
        config.addResource(new org.apache.hadoop.fs.Path(file.toURI()));
    } catch (Exception exception) {
        Assert.fail("Cannot create hdfs-version-site file:[" + exception.getMessage() + "]");
    }
    authorizer = new RangerHdfsAuthorizer();
    authorizer.start();
    AccessControlEnforcer accessControlEnforcer = Mockito.mock(AccessControlEnforcer.class);
    rangerControlEnforcer = authorizer.getExternalAccessControlEnforcer(accessControlEnforcer);
}
Also used : RangerHdfsAuthorizer(org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) AccessControlEnforcer(org.apache.hadoop.hdfs.server.namenode.INodeAttributeProvider.AccessControlEnforcer) File(java.io.File) RangerConfiguration(org.apache.ranger.authorization.hadoop.config.RangerConfiguration) AccessControlException(org.apache.hadoop.security.AccessControlException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BeforeClass(org.junit.BeforeClass)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 AccessControlEnforcer (org.apache.hadoop.hdfs.server.namenode.INodeAttributeProvider.AccessControlEnforcer)1 AccessControlException (org.apache.hadoop.security.AccessControlException)1 RangerHdfsAuthorizer (org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer)1 RangerConfiguration (org.apache.ranger.authorization.hadoop.config.RangerConfiguration)1 BeforeClass (org.junit.BeforeClass)1