Skip to content

Commit

Permalink
fix: create default user+group before provisioning (#1541)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDombo authored Oct 10, 2023
1 parent b658c70 commit 7dbe35d
Show file tree
Hide file tree
Showing 66 changed files with 66 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
public class DockerImageArtifactDownload01Test extends BaseITCase {

private final PlatformResolver platformResolver = new PlatformResolver(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
public class DockerImageArtifactDownloadTest extends BaseITCase {

private final PlatformResolver platformResolver = new PlatformResolver(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import static org.mockito.Mockito.when;
import static software.amazon.awssdk.services.greengrassv2.model.DeploymentComponentUpdatePolicyAction.NOTIFY_COMPONENTS;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class ServiceDependencyLifecycleTest extends BaseITCase {
private static final String CustomerApp = "CustomerApp";
private static final String HardDependency = "HardDependency";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
public class UnloadableServiceIntegTest extends BaseITCase {

private Kernel kernel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ void performSetup() throws IOException, DeviceConfigurationException, URISyntaxE
}

DeviceConfiguration deviceConfiguration = kernel.getContext().get(DeviceConfiguration.class);
setComponentDefaultUserAndGroup(deviceConfiguration);
if (needProvisioning) {
if (Utils.isEmpty(awsRegion)) {
awsRegion = Coerce.toString(deviceConfiguration.getAWSRegion());
Expand All @@ -324,9 +325,6 @@ void performSetup() throws IOException, DeviceConfigurationException, URISyntaxE
provision(kernel);
}

// Attempt this only after config file and Nucleus args have been parsed
setComponentDefaultUserAndGroup(deviceConfiguration);

if (setupSystemService) {
kernel.getContext().get(KernelLifecycle.class).softShutdown(30);
boolean ok = kernel.getContext().get(SystemServiceUtilsFactory.class).getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class AuthorizationHandlerTest {

@Mock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class AuthorizationIPCAgentTest {
private static final String TEST_TOKEN = "token";
@Mock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class AuthorizationPolicyParserTest {

private final static String TEST_COMPONENT = "testComponent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
@SuppressWarnings("PMD.CloseResource")
class ConfigStoreIPCEventStreamAgentTest {
private static final String TEST_COMPONENT_A = "Component_A";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class LifecycleIPCEventStreamAgentTest {

private static final String TEST_SERVICE = "TestService";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class MqttProxyIPCAgentTest {
private static final String TEST_SERVICE = "TestService";
private static final String TEST_TOPIC = "TestTopic";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class PubSubIPCEventStreamAgentTest {
private static final String TEST_SERVICE = "TestService";
private static final String TEST_TOPIC = "TestTopic";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
public class ComponentMetricIPCEventStreamAgentTest {
private static final String VALID_TEST_COMPONENT = "aws.greengrass.testcomponent";
private static final String STREAM_MANAGER_COMPONENT = "aws.greengrass.StreamManager";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class ClientConfigurationUtilsTest {
@Mock
private SecurityService securityService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
import static org.mockito.Mockito.when;


@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class ComponentManagerTest {

private static final ObjectMapper MAPPER = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class ComponentServiceHelperTest {

private static final Semver v1_0_0 = new Semver("1.0.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
* files from its test resource folder if it needs to mock some recipe/artifact. It doesn't and shouldn't use or assume
* any static folder directly as package store. The package store folder is deleted after each test.
*/
@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class ComponentStoreTest {
private static final String MONITORING_SERVICE_PKG_NAME = "MonitoringService";
private static final Semver MONITORING_SERVICE_PKG_VERSION = new Semver("1.0.0", Semver.SemverType.NPM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
import static org.mockito.Mockito.when;
import static software.amazon.awssdk.services.greengrassv2.model.DeploymentComponentUpdatePolicyAction.NOTIFY_COMPONENTS;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DependencyResolverTest {

private static final Semver v1_5_0 = new Semver("1.5.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
@SuppressWarnings("PMD.ExcessiveClassLength")
class KernelConfigResolverTest {
private static final String LIFECYCLE_INSTALL_KEY = "install";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import static org.hamcrest.core.Is.is;
import static org.junit.jupiter.api.Assertions.assertThrows;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class ArtifactDownloaderFactoryTest {

Path testDir = Paths.get("foo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class ArtifactDownloaderTest {

private static final String LOCAL_FILE_NAME = "artifact.txt";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class GreengrassRepositoryDownloaderTest {
private static final String SHA256 = "SHA-256";
private static final String TEST_ARN = "arn";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class S3DownloaderTest {

private static final String VALID_ARTIFACT_URI = "s3://eg-artifacts/ComponentWithS3Artifacts-1.0.0/artifact.txt";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
public class DockerImageArtifactParserTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
public class DockerImageDownloaderTest {
private static ComponentIdentifier TEST_COMPONENT_ID =
new ComponentIdentifier("test.container.component", new Semver("1.0.0"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
public class EcrAccessorTest {
@Mock
private EcrClient ecrClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
import static software.amazon.awssdk.services.greengrassv2.model.DeploymentComponentUpdatePolicyAction.SKIP_NOTIFY_COMPONENTS;


@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DeploymentConfigMergerTest {

private final Logger logger = LogManager.getLogger(this.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.internal.verification.VerificationModeFactory.times;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DeploymentDirectoryManagerTest {
private static final String mockArn = "arn:aws:greengrass:us-east-1:12345678910:configuration:thinggroup/group1:1";
private static final String expectedDirectoryName =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DeploymentDocumentDownloaderTest {
private static final String THING_NAME = "myThing";
private static final String DEPLOYMENT_ID = "deploymentId";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
public class DeploymentQueueTest {
private static final DeploymentDocument TEST_DEPLOYMENT_DOCUMENT = new DeploymentDocument();
private static final String TEST_DEPLOYMENT_ID_1 = "deployment-1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
import static org.mockito.Mockito.when;

@SuppressWarnings({"PMD.LooseCoupling", "PMD.TestClassWithoutTestCases"})
@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DeploymentServiceTest extends GGServiceTestUtil {

private static final String TEST_JOB_ID_1 = "TEST_JOB_1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DeploymentTaskTest {

private static final String COMPONENT_2_ROOT_PACKAGE_NAME = "component2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DeviceConfigurationTest {
@Mock
Kernel mockKernel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DynamicComponentConfigurationValidatorTest {
private static final String DEFAULT_EXISTING_SERVICE_VERSION = "1.0.0";
private static final long DEFAULT_EXISTING_NODE_MOD_TIME = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class IotJobsHelperTest {

private static final String TEST_THING_NAME = "TEST_THING";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class KernelUpdateDeploymentTaskTest {
private static final Logger logger = LogManager.getLogger(KernelUpdateDeploymentTaskTest.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class ThingGroupHelperTest {
@Mock
private DeviceConfiguration deviceConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DeploymentActivatorFactoryTest {
@Mock
Kernel kernel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class KernelUpdateActivatorTest {
@Mock
Kernel kernel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class BootstrapManagerTest {
private static final String componentA = "componentA";
private static final String componentB = "componentB";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DeploymentErrorCodeUtilsTest {

@Mock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
import static org.mockito.Mockito.when;

@SuppressWarnings("PMD.CouplingBetweenObjects")
@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class DeviceProvisioningHelperTest {
private static final String TEST_REGION = "us-east-1";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith({MockitoExtension.class, GGExtension.class})
@ExtendWith({GGExtension.class, MockitoExtension.class})
class GreengrassSetupTest {
@Mock
private DeviceProvisioningHelper deviceProvisioningHelper;
Expand Down
Loading

0 comments on commit 7dbe35d

Please sign in to comment.