Search in sources :

Example 6 with UserParam

use of org.apache.hadoop.hdfs.web.resources.UserParam in project hadoop by apache.

the class TestWebHdfsUrl method testCheckAccessUrl.

@Test(timeout = 60000)
public void testCheckAccessUrl() throws IOException {
    Configuration conf = new Configuration();
    UserGroupInformation ugi = UserGroupInformation.createRemoteUser("test-user");
    UserGroupInformation.setLoginUser(ugi);
    WebHdfsFileSystem webhdfs = getWebHdfsFileSystem(ugi, conf);
    Path fsPath = new Path("/p1");
    URL checkAccessUrl = webhdfs.toUrl(GetOpParam.Op.CHECKACCESS, fsPath, new FsActionParam(FsAction.READ_WRITE));
    checkQueryParams(new String[] { GetOpParam.Op.CHECKACCESS.toQueryString(), new UserParam(ugi.getShortUserName()).toString(), FsActionParam.NAME + "=" + FsAction.READ_WRITE.SYMBOL }, checkAccessUrl);
}
Also used : Path(org.apache.hadoop.fs.Path) UserParam(org.apache.hadoop.hdfs.web.resources.UserParam) Configuration(org.apache.hadoop.conf.Configuration) URL(java.net.URL) FsActionParam(org.apache.hadoop.hdfs.web.resources.FsActionParam) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Example 7 with UserParam

use of org.apache.hadoop.hdfs.web.resources.UserParam in project hadoop by apache.

the class TestWebHdfsUrl method testSimpleProxyAuthParamsInUrl.

@Test(timeout = 60000)
public void testSimpleProxyAuthParamsInUrl() throws IOException {
    Configuration conf = new Configuration();
    UserGroupInformation ugi = UserGroupInformation.createRemoteUser("test-user");
    ugi = UserGroupInformation.createProxyUser("test-proxy-user", ugi);
    UserGroupInformation.setLoginUser(ugi);
    WebHdfsFileSystem webhdfs = getWebHdfsFileSystem(ugi, conf);
    Path fsPath = new Path("/");
    // send real+effective
    URL fileStatusUrl = webhdfs.toUrl(GetOpParam.Op.GETFILESTATUS, fsPath);
    checkQueryParams(new String[] { GetOpParam.Op.GETFILESTATUS.toQueryString(), new UserParam(ugi.getRealUser().getShortUserName()).toString(), new DoAsParam(ugi.getShortUserName()).toString() }, fileStatusUrl);
}
Also used : Path(org.apache.hadoop.fs.Path) UserParam(org.apache.hadoop.hdfs.web.resources.UserParam) Configuration(org.apache.hadoop.conf.Configuration) DoAsParam(org.apache.hadoop.hdfs.web.resources.DoAsParam) URL(java.net.URL) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Aggregations

UserParam (org.apache.hadoop.hdfs.web.resources.UserParam)7 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)7 Test (org.junit.Test)7 URL (java.net.URL)6 Configuration (org.apache.hadoop.conf.Configuration)6 Path (org.apache.hadoop.fs.Path)6 DelegationParam (org.apache.hadoop.hdfs.web.resources.DelegationParam)2 DoAsParam (org.apache.hadoop.hdfs.web.resources.DoAsParam)2 TokenArgumentParam (org.apache.hadoop.hdfs.web.resources.TokenArgumentParam)2 QueryStringDecoder (io.netty.handler.codec.http.QueryStringDecoder)1 FsActionParam (org.apache.hadoop.hdfs.web.resources.FsActionParam)1 LengthParam (org.apache.hadoop.hdfs.web.resources.LengthParam)1 OffsetParam (org.apache.hadoop.hdfs.web.resources.OffsetParam)1 StartAfterParam (org.apache.hadoop.hdfs.web.resources.StartAfterParam)1