Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for localhost in correct table #7445

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
import com.redhat.rhn.domain.channel.ContentSource;
import com.redhat.rhn.domain.channel.PublicChannelFamily;
import com.redhat.rhn.domain.cloudpayg.CloudRmtHostFactory;
import com.redhat.rhn.domain.cloudpayg.PaygProductFactory;
import com.redhat.rhn.domain.cloudpayg.PaygSshData;
import com.redhat.rhn.domain.cloudpayg.PaygSshDataFactory;
Expand Down Expand Up @@ -786,7 +785,7 @@ public boolean isRefreshNeeded(String mirrorUrl) {
);
}
else if (CredentialsFactory.listSCCCredentials().isEmpty() && !(cloudPaygManager.isPaygInstance() &&
CloudRmtHostFactory.lookupByHostname("localhost").isPresent())) {
PaygSshDataFactory.lookupByHostname("localhost").isPresent())) {
// Can happen when neither SCC Credentials nor fromdir is configured
// Also when we are PAYG instance, but localhost connection is not configured
// in such a case, refresh makes no sense.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
import com.redhat.rhn.domain.channel.ContentSource;
import com.redhat.rhn.domain.channel.test.ChannelFamilyFactoryTest;
import com.redhat.rhn.domain.cloudpayg.PaygSshData;
import com.redhat.rhn.domain.cloudpayg.PaygSshDataFactory;
import com.redhat.rhn.domain.common.ManagerInfoFactory;
import com.redhat.rhn.domain.credentials.Credentials;
import com.redhat.rhn.domain.credentials.CredentialsFactory;
Expand Down Expand Up @@ -66,6 +68,7 @@
import com.redhat.rhn.testing.BaseTestCaseWithUser;
import com.redhat.rhn.testing.TestUtils;

import com.suse.cloud.CloudPaygManager;
import com.suse.manager.webui.services.pillar.MinionGeneralPillarGenerator;
import com.suse.manager.webui.services.pillar.MinionPillarManager;
import com.suse.mgrsync.MgrSyncStatus;
Expand Down Expand Up @@ -2046,6 +2049,30 @@ public void testIsRefreshNeededNothingConfigured() throws Exception {
assertFalse(csm.isRefreshNeeded(null));
}

@Test
public void testIsRefreshNeededPAYG() {
for (Credentials c : CredentialsFactory.listSCCCredentials()) {
CredentialsFactory.removeCredentials(c);
}
ManagerInfoFactory.setLastMgrSyncRefresh(0);
CloudPaygManager mgr = new CloudPaygManager();
mgr.setPaygInstance(true);
mgr.setCompliant(true);
ContentSyncManager csm = new ContentSyncManager(null, mgr);
Credentials rmtCreds = CredentialsFactory.createCloudRmtCredentials();
rmtCreds.setUsername("RMTUSER");
rmtCreds.setPassword("secret");
CredentialsFactory.storeCredentials(rmtCreds);
PaygSshData sshData = PaygSshDataFactory.createPaygSshData();
sshData.setHost("localhost");
sshData.setUsername("admin");
sshData.setPassword("secret");
sshData.setCredentials(rmtCreds);
PaygSshDataFactory.savePaygSshData(sshData);

assertTrue(csm.isRefreshNeeded(null));
}

/**
* Test generation of channels for PTF repositories per module
* @throws Exception if anything goes wrong
Expand Down
Loading