CognosContainer
from skipcheck_tm1_testcontainers import CognosContainer IBM Cognos Analytics in Docker, for tests, built on the cognos-server image:
the security (CAM) a TM1 server in CAM mode takes its users from.
Give it test users, and the container builds an LDAP directory with them and a Cognos
namespace (LDAP) for it. Then run a Tm1ServerContainer against
it with Tm1ServerContainer.with_cam_security, and log in to TM1 as each test
user:
cognos = CognosContainer(cognos_source).with_user("admin", "adminpw", "Admins").with_user("viewer", "viewerpw", "Readers")
# Entering the block starts the server, and Cognos first; leaving it stops the server
with cognos, Tm1ServerContainer(tm1_source).with_cam_security(cognos, "admin") as server:
# Each test user logs in with their own identity, through the LDAP namespace
viewer = auth.cam_namespace("viewer", "viewerpw", CognosContainer.NAMESPACE)
with Tm1Client.builder().base_url(server.rest_url).authenticator(viewer).build() as tm1:
# TM1 knows the user by their CAMID
return tm1.users.active_user(ODataQuery.none().select(User.NAME)).name
Cognos is heavy: it takes about two minutes to start and uses about 8 GB of memory, so
Docker needs at least 12 GB. Every user is a Cognos administrator (a new content store
puts Everyone there); TM1's own security comes from the groups. The image contains no
IBM software, so every container needs a CognosSource.
Members
DEFAULT_IMAGE | The cognos-server image, without a tag. |
SERVER_IMAGE | Overrides the cognos-server image (not used with PrivateImage), e.g. |
DISPATCHER_PORT | The Cognos dispatcher's port inside the container. |
NETWORK_ALIAS | The container's host name and network alias, which Cognos's dispatcher URIs name. |
NAMESPACE | The ID of the LDAP namespace the test users are in. |
Namespace | |
User | |
__init__ constructor | A container on the default cognos-server image (or COGNOS_SERVER_IMAGE), getting Cognos from source. |
with_user | Adds a test user to the LDAP namespace, in groups that are created as needed. |
with_keycloak | Adds an OIDC namespace backed by Keycloak, on one network with it. |
keycloak property | The Keycloak set with with_keycloak, or None if there's no OIDC namespace. |
users property | The test users, in the order they were added. |
get_user | A test user by name. |
groups property | Every test user's groups, once each, in the order they were added. |
source property | Where Cognos comes from. |
url property | Cognos as seen from the host, such as http://localhost:54321/bi/, ending in /. |
network_url property | The dispatcher, as other containers on the network reach it. |
cam_authorization | A test user's CAMNamespace logon, for TM1 in CAM security. |
passport | A CAM passport for an OIDC ID token (from KeycloakContainer.id_token). |
cam_authorization_for static | CAMNamespace with user:password:namespace. |
users_spec | The users as the image's COGNOS_USERS takes them. |
configure | Called by testcontainers before the container is created. |
container_is_started | Called once the container is up. |
DEFAULT_IMAGE
DEFAULT_IMAGE: ClassVar[str]The cognos-server image, without a tag.
SERVER_IMAGE
SERVER_IMAGE: ClassVar[str] Overrides the cognos-server image (not used with
PrivateImage), e.g. cognos-server:local for a local
build. Read as a system property, then an environment variable.
DISPATCHER_PORT
DISPATCHER_PORT: ClassVar[int]The Cognos dispatcher's port inside the container.
NETWORK_ALIAS
NETWORK_ALIAS: ClassVar[str] The container's host name and network alias, which Cognos's dispatcher URIs name.
Other containers on its network reach it at http://cognos:9300.
NAMESPACE
NAMESPACE: ClassVar[str]The ID of the LDAP namespace the test users are in: the CAMNamespace.
Namespace
Namespace: ClassVar[type[Namespace]]User
User: ClassVar[type[User]]__init__
constructor__init__(source: CognosSource, image: str | None = None) -> None A container on the default cognos-server image (or
COGNOS_SERVER_IMAGE), getting Cognos from source.
with_user
with_user(name: str, password: str, *groups: str) -> SelfAdds a test user to the LDAP namespace, in groups that are created as needed.
with_keycloak
with_keycloak(keycloak: KeycloakContainer) -> SelfAdds an OIDC namespace backed by Keycloak, on one network with it.
keycloak
propertykeycloak: KeycloakContainer | NoneThe Keycloak set with with_keycloak, or None if there's no OIDC namespace.
users
propertyusers: list[User]The test users, in the order they were added.
get_user
get_user(name: str) -> UserA test user by name. A ValueError if there's no such user.
groups
propertygroups: list[str]Every test user's groups, once each, in the order they were added.
source
propertysource: CognosSourceWhere Cognos comes from.
url
propertyurl: strCognos as seen from the host, such as http://localhost:54321/bi/, ending in /.
network_url
propertynetwork_url: strThe dispatcher, as other containers on the network reach it.
cam_authorization
cam_authorization(user: str, namespace: Namespace = Namespace.LDAP) -> strA test user's CAMNamespace logon, for TM1 in CAM security.
passport
passport(id_token: str) -> strA CAM passport for an OIDC ID token (from KeycloakContainer.id_token).
cam_authorization_for
staticcam_authorization_for(user: str, password: str, namespace: str) -> strCAMNamespace with user:password:namespace: Java's static camAuthorization.
users_spec
users_spec() -> strThe users as the image's COGNOS_USERS takes them.
configure
configure() -> NoneCalled by testcontainers before the container is created: passes the test users to the image as COGNOS_USERS.
container_is_started
container_is_started() -> NoneCalled once the container is up: logs where it is and what it came from.