Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Reference and Helper Services
CRS Catalog
Commits
9ad25cfc
Commit
9ad25cfc
authored
Oct 14, 2020
by
Anuj Gupta
Browse files
Merge branch 'ibm-impl-int-test' into 'master'
Added IBM impl and int test See merge request
!8
parents
287661cc
18cc2263
Pipeline
#12019
passed with stages
in 12 minutes and 23 seconds
Changes
12
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
NOTICE
View file @
9ad25cfc
...
...
@@ -86,6 +86,7 @@ The following software have components provided under the terms of this license:
- JSON Web Token support for the JVM (from https://github.com/jwtk/jjwt.git)
- JSON library from Android SDK (from http://developer.android.com/sdk)
- JSONassert (from https://github.com/skyscreamer/JSONassert)
- Jackson dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary)
- Jackson datatype: JSR310 (from http://wiki.fasterxml.com/JacksonModuleJSR310)
- Jackson-annotations (from http://github.com/FasterXML/jackson)
- Jackson-core (from https://github.com/FasterXML/jackson-core)
...
...
pom.xml
View file @
9ad25cfc
...
...
@@ -39,6 +39,7 @@
<module>
crs-catalog-core
</module>
<module>
provider/crs-catalog-azure/crs-catalog-aks
</module>
<module>
provider/crs-catalog-gcp/crs-catalog-gke
</module>
<module>
provider/crs-catalog-ibm/crs-catalog-ocp
</module>
</modules>
<repositories>
...
...
provider/crs-catalog-ibm/crs-catalog-ocp/pom.xml
0 → 100644
View file @
9ad25cfc
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.opengroup.osdu.crs-catalog-service
</groupId>
<artifactId>
crs-catalog-service
</artifactId>
<version>
1.0.0
</version>
</parent>
<packaging>
jar
</packaging>
<artifactId>
crs-catalog-ocp
</artifactId>
<name>
crs-catalog-ocp
</name>
<description>
CRS Catalog service Openshift Container Platform deployment
</description>
<repositories>
<repository>
<id>
${gitlab-server}
</id>
<url>
https://community.opengroup.org/api/v4/groups/17/-/packages/maven
</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>
${gitlab-server}
</id>
<url>
https://community.opengroup.org/api/v4/projects/21/packages/maven
</url>
</repository>
<snapshotRepository>
<id>
${gitlab-server}
</id>
<url>
https://community.opengroup.org/api/v4/projects/21/packages/maven
</url>
</snapshotRepository>
</distributionManagement>
<properties>
<app.version>
1
</app.version>
<app.id>
crs-catalog-ocp
</app.id>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<objectify.version>
5.1.22
</objectify.version>
<os-core-lib-ibm.version>
0.3.6-SNAPSHOT
</os-core-lib-ibm.version>
<slf4j.version>
1.7.25
</slf4j.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.showDeprecation>
true
</maven.compiler.showDeprecation>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
</properties>
<prerequisites>
<maven>
3.1.0
</maven>
</prerequisites>
<dependencies>
<dependency>
<groupId>
org.opengroup.osdu.crs-catalog-service
</groupId>
<artifactId>
crs-catalog-core
</artifactId>
<version>
1.0.0
</version>
</dependency>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>
javax.jdo
</groupId>
<artifactId>
jdo-api
</artifactId>
<version>
3.1
</version>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.8.5
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.2
</version>
<scope>
provided
</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.powermock
</groupId>
<artifactId>
powermock-module-junit4
</artifactId>
<version>
${powermock.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.powermock
</groupId>
<artifactId>
powermock-api-mockito2
</artifactId>
<version>
${powermock.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-core
</artifactId>
<version>
3.3.3
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
cobertura-maven-plugin
</artifactId>
<version>
2.7
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
os-core-lib-ibm
</artifactId>
<version>
${os-core-lib-ibm.version}
</version>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application-->
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
<plugin>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
versions-maven-plugin
</artifactId>
<version>
2.7
</version>
<executions>
<execution>
<goals>
<goal>
display-dependency-updates
</goal>
<goal>
display-plugin-updates
</goal>
</goals>
<configuration>
<classifier>
spring-boot
</classifier>
<mainClass>
org.opengroup.osdu.crs.CrsOcpApplication
</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<version>
3.7.0
</version>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
</configuration>
</plugin>
<plugin>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.21.0
</version>
<configuration>
<redirectTestOutputToFile>
true
</redirectTestOutputToFile>
<!--
<testFailureIgnore>true</testFailureIgnore>
-->
</configuration>
</plugin>
</plugins>
</build>
</project>
provider/crs-catalog-ibm/crs-catalog-ocp/src/main/java/org/opengroup/osdu/crs/CrsOcpApplication.java
0 → 100644
View file @
9ad25cfc
// Copyright 2017-2019, IBM
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package
org.opengroup.osdu.crs
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
public
class
CrsOcpApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
CrsOcpApplication
.
class
,
args
);
}
}
provider/crs-catalog-ibm/crs-catalog-ocp/src/main/java/org/opengroup/osdu/crs/CrsOcpConfiguration.java
0 → 100644
View file @
9ad25cfc
package
org.opengroup.osdu.crs
;
import
org.opengroup.osdu.crs.model.CatalogImpl
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.ClassPathResource
;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.util.logging.Logger
;
@Configuration
public
class
CrsOcpConfiguration
{
private
static
Logger
logger
=
Logger
.
getLogger
(
CrsOcpConfiguration
.
class
.
getName
());
private
static
final
String
DEFAULT_CATALOG_FILE
=
"crs_catalog_v2.json"
;
// later make it as config map and mount it as file on oc cluster.
@Bean
public
CatalogImpl
getCatalog
(
@Value
(
"${osdu.crs.catalog.filename:null}"
)
String
location
)
throws
Exception
{
logger
.
info
(
"osdu.crs.catalog.filename"
+
location
);
try
(
FileReader
reader
=
new
FileReader
(
location
))
{
return
CatalogImpl
.
createCatalog
(
reader
);
}
catch
(
NullPointerException
e
)
{
logger
.
info
(
"osdu.crs.catalog.filename"
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
info
(
"File not found"
);
}
ClassPathResource
cpr
=
new
ClassPathResource
(
DEFAULT_CATALOG_FILE
);
InputStream
inputStream
=
cpr
.
getInputStream
();
Reader
reader
=
new
InputStreamReader
(
inputStream
);
return
CatalogImpl
.
createCatalog
(
reader
);
}
}
provider/crs-catalog-ibm/crs-catalog-ocp/src/main/java/org/opengroup/osdu/crs/security/SecurityConfig.java
0 → 100644
View file @
9ad25cfc
package
org.opengroup.osdu.crs.security
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.config.http.SessionCreationPolicy
;
@EnableWebSecurity
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
csrf
().
disable
()
.
sessionManagement
().
sessionCreationPolicy
(
SessionCreationPolicy
.
NEVER
)
.
and
()
.
authorizeRequests
()
//.antMatchers(ALLOWED_URLS).permitAll()
.
antMatchers
(
"/"
,
"/index.html"
,
"/v2/api-docs"
,
"/configuration/ui"
,
"/swagger-resources/**"
,
"/configuration/security"
,
"/swagger"
,
"/swagger-ui.html"
,
"/webjars/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
.
and
()
.
oauth2ResourceServer
().
jwt
();
}
}
provider/crs-catalog-ibm/crs-catalog-ocp/src/main/resources/application.properties
0 → 100644
View file @
9ad25cfc
LOG_PREFIX
=
crs-catalog
server.servlet.contextPath
=
/api/crs/catalog/
logging.level.org.springframework.web
=
DEBUG
server.port
=
8080
# Entitlement properties
#
#
# [Required] URL of the Entitlements Service
osdu.entitlement.url
=
${ENTITLEMENT_URL}
spring.security.oauth2.resourceserver.jwt.jwk-set-uri
=
${keycloack.certs.uri}
# Other properties
#
#
# [Optional] [AKS] [GKE] File location of the crs catalog
osdu.crs.catalog.filename
=
${CRS_CATALOG_FILENAME:/mnt/crs_catalog_catalogs/crs_catalog_v2.json}
provider/crs-catalog-ibm/crs-catalog-ocp/src/main/resources/crs_catalog_v2.json
0 → 100644
View file @
9ad25cfc
This diff is collapsed.
Click to expand it.
testing/catalog_test_ibm/.env.example
0 → 100644
View file @
9ad25cfc
KEYCLOAK_URL=
KEYCLOAK_REALM=
KEYCLOAK_CLIENT_ID=
KEYCLOAK_CLIENT_SECRET=
AUTH_USER_ACCESS=
AUTH_USER_ACCESS_PASSWORD=
VIRTUAL_SERVICE_HOST_NAME=
MY_TENANT=opendes
testing/catalog_test_ibm/jwt_client.py
0 → 100644
View file @
9ad25cfc
import
os
from
keycloak
import
KeycloakOpenID
def
get_id_token
():
keycloak_host
=
os
.
getenv
(
'KEYCLOAK_URL'
)
keycloak_realm
=
os
.
getenv
(
'KEYCLOAK_REALM'
,
"OSDU"
)
client_id
=
os
.
getenv
(
'KEYCLOAK_CLIENT_ID'
)
client_secret
=
os
.
getenv
(
'KEYCLOAK_CLIENT_SECRET'
)
user
=
os
.
getenv
(
'AUTH_USER_ACCESS'
)
password
=
os
.
getenv
(
'AUTH_USER_ACCESS_PASSWORD'
)
try
:
# Configure client
keycloak_openid
=
KeycloakOpenID
(
server_url
=
"https://"
+
keycloak_host
+
"/auth/"
,
client_id
=
client_id
,
realm_name
=
keycloak_realm
,
client_secret_key
=
client_secret
)
token
=
keycloak_openid
.
token
(
user
,
password
)
return
token
[
'access_token'
]
except
Exception
as
e
:
print
(
e
)
def
get_invalid_token
():
'''
This is dummy jwt
{
"sub": "dummy@dummy.com",
"iss": "dummy@dummy.com",
"aud": "dummy.dummy.com",
"iat": 1556137273,
"exp": 1556223673,
"provider": "dummy.com",
"client": "dummy.com",
"userid": "dummytester.com",
"email": "dummytester.com",
"authz": "",
"lastname": "dummy",
"firstname": "dummy",
"country": "",
"company": "",
"jobtitle": "",
"subid": "dummyid",
"idp": "dummy",
"hd": "dummy.com",
"desid": "dummyid",
"contact_email": "dummy@dummy.com"
}
'''
return
"fake.token"
\ No newline at end of file
testing/catalog_test_ibm/requirements.txt
0 → 100644
View file @
9ad25cfc
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
cryptography==2.8
idna==2.9
pycparser==2.20
PyJWT==1.7.1
python-dateutil==2.8.1
requests==2.23.0
six==1.14.0
urllib3==1.25.8
python-keycloak==0.21.0
python-dotenv==0.14.0
testing/catalog_test_ibm/run_test.py
0 → 100644
View file @
9ad25cfc
import
sys
sys
.
path
.
append
(
".."
)
from
dotenv
import
load_dotenv
load_dotenv
()
from
catalog_test_core.test_crs_catalog_v2
import
*
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment