Skip to content

Commit

Permalink
update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalmer committed Jan 20, 2025
1 parent 8d29584 commit 09ce9ae
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions java/code/src/com/suse/manager/hub/test/HubManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@
import com.redhat.rhn.domain.credentials.HubSCCCredentials;
import com.redhat.rhn.domain.credentials.SCCCredentials;
import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.domain.server.MgrServerInfo;
import com.redhat.rhn.domain.server.MinionServer;
import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
import com.redhat.rhn.manager.entitlement.EntitlementManager;
import com.redhat.rhn.manager.formula.FormulaMonitoringManager;
import com.redhat.rhn.manager.setup.MirrorCredentialsManager;
import com.redhat.rhn.manager.system.ServerGroupManager;
Expand All @@ -56,6 +60,7 @@
import com.suse.manager.webui.services.iface.SaltApi;
import com.suse.manager.webui.services.iface.VirtManager;
import com.suse.manager.webui.services.test.TestSaltApi;
import com.suse.manager.webui.utils.gson.ManagerInfoJson;
import com.suse.manager.webui.utils.token.Token;
import com.suse.manager.webui.utils.token.TokenBuildingException;
import com.suse.manager.webui.utils.token.TokenParser;
Expand Down Expand Up @@ -442,6 +447,8 @@ public void canRegisterPeripheralWithUserNameAndPassword()
wifQ.XldOvQJypIkb4E1am0JlBxsHYrx_7J77s1\
vTrvoNlEU""";

ManagerInfoJson mgrInfo = new ManagerInfoJson("5.1.0", true, "reportdb", REMOTE_SERVER_FQDN, 5432);

context().checking(new Expectations() {{
allowing(clientFactoryMock).newExternalClient(REMOTE_SERVER_FQDN, "admin", "admin", null);
will(returnValue(externalClient));
Expand All @@ -461,6 +468,11 @@ public void canRegisterPeripheralWithUserNameAndPassword()
);

allowing(internalClient).storeCredentials(with(any(String.class)), with(any(String.class)));

allowing(internalClient).getManagerInfo();
will(returnValue(mgrInfo));

allowing(internalClient).storeReportDbCredentials(with(any(String.class)), with(any(String.class)));
}});

// Register the remote server as PERIPHERAL for this local server
Expand All @@ -477,6 +489,18 @@ public void canRegisterPeripheralWithUserNameAndPassword()

var issued = hubFactory.lookupAccessTokenByFqdnAndType(REMOTE_SERVER_FQDN, TokenType.ISSUED);
assertNotNull(issued);

Optional<Server> optServer = ServerFactory.findByFqdn(REMOTE_SERVER_FQDN);
if (optServer.isPresent()) {
Server srv = optServer.get();
MgrServerInfo mgrServerInfo = srv.getMgrServerInfo();
assertEquals(mgrInfo.getReportDbName(), mgrServerInfo.getReportDbName());
assertEquals(mgrInfo.getVersion(), mgrServerInfo.getVersion().getVersion());
assertTrue(srv.hasEntitlement(EntitlementManager.FOREIGN));
}
else {
fail("Server not found");
}
}

@Test
Expand Down

0 comments on commit 09ce9ae

Please sign in to comment.