29
29
import com .facebook .presto .testing .QueryRunner ;
30
30
import com .google .common .collect .ImmutableMap ;
31
31
import org .apache .iceberg .Table ;
32
+ import org .apache .iceberg .rest .RESTCatalog ;
32
33
import org .assertj .core .util .Files ;
33
34
import org .testng .annotations .AfterClass ;
34
35
import org .testng .annotations .BeforeClass ;
42
43
import static com .facebook .presto .iceberg .FileFormat .PARQUET ;
43
44
import static com .facebook .presto .iceberg .IcebergQueryRunner .ICEBERG_CATALOG ;
44
45
import static com .facebook .presto .iceberg .IcebergUtil .getNativeIcebergTable ;
46
+ import static com .facebook .presto .iceberg .rest .AuthenticationType .OAUTH2 ;
45
47
import static com .facebook .presto .iceberg .rest .IcebergRestTestUtil .getRestServer ;
46
48
import static com .facebook .presto .iceberg .rest .IcebergRestTestUtil .restConnectorProperties ;
47
49
import static com .google .common .io .MoreFiles .deleteRecursively ;
48
50
import static com .google .common .io .RecursiveDeleteOption .ALLOW_INSECURE ;
49
51
import static java .lang .String .format ;
52
+ import static org .apache .iceberg .rest .auth .OAuth2Properties .OAUTH2_SERVER_URI ;
50
53
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
54
+ import static org .testng .Assert .assertEquals ;
51
55
52
56
@ Test
53
57
public class TestIcebergSmokeRest
@@ -106,12 +110,11 @@ protected QueryRunner createQueryRunner()
106
110
Optional .of (warehouseLocation .toPath ()));
107
111
}
108
112
109
- protected IcebergNativeCatalogFactory getCatalogFactory ()
113
+ protected IcebergNativeCatalogFactory getCatalogFactory (IcebergRestConfig restConfig )
110
114
{
111
115
IcebergConfig icebergConfig = new IcebergConfig ()
112
116
.setCatalogType (REST )
113
- .setCatalogWarehouse (warehouseLocation .getAbsolutePath ().toString ());
114
- IcebergRestConfig restConfig = new IcebergRestConfig ().setServerUri (serverUri );
117
+ .setCatalogWarehouse (warehouseLocation .getAbsolutePath ());
115
118
116
119
return new IcebergRestCatalogFactory (
117
120
icebergConfig ,
@@ -125,7 +128,8 @@ protected IcebergNativeCatalogFactory getCatalogFactory()
125
128
@ Override
126
129
protected Table getIcebergTable (ConnectorSession session , String schema , String tableName )
127
130
{
128
- return getNativeIcebergTable (getCatalogFactory (),
131
+ IcebergRestConfig restConfig = new IcebergRestConfig ().setServerUri (serverUri );
132
+ return getNativeIcebergTable (getCatalogFactory (restConfig ),
129
133
session ,
130
134
SchemaTableName .valueOf (schema + "." + tableName ));
131
135
}
@@ -192,4 +196,20 @@ public void testMetadataDeleteOnTableWithUnsupportedSpecsWhoseDataAllDeleted(Str
192
196
super .testMetadataDeleteOnTableWithUnsupportedSpecsWhoseDataAllDeleted (version , mode );
193
197
}
194
198
}
199
+
200
+ @ Test
201
+ public void testSetOauth2ServerUriPropertyI ()
202
+ {
203
+ String authEndpoint = "http://localhost:8888" ;
204
+ IcebergRestConfig restConfig = new IcebergRestConfig ()
205
+ .setServerUri (serverUri )
206
+ .setAuthenticationType (OAUTH2 )
207
+ .setToken ("SXVLUXUhIExFQ0tFUiEK" )
208
+ .setAuthenticationServerUri (authEndpoint );
209
+
210
+ IcebergRestCatalogFactory catalogFactory = (IcebergRestCatalogFactory ) getCatalogFactory (restConfig );
211
+ RESTCatalog catalog = (RESTCatalog ) catalogFactory .getCatalog (getSession ().toConnectorSession ());
212
+
213
+ assertEquals (catalog .properties ().get (OAUTH2_SERVER_URI ), authEndpoint );
214
+ }
195
215
}
0 commit comments