| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,8 +16,6 @@ | |||
| 16 | 16 | import java.nio.file.Path; | |
| 17 | 17 | import java.nio.file.Paths; | |
| 18 | 18 | import java.util.concurrent.TimeUnit; | |
| 19 | - import java.util.regex.Matcher; | ||
| 20 | - import java.util.regex.Pattern; | ||
| 21 | 19 | ||
| 22 | 20 | import static org.hamcrest.MatcherAssert.assertThat; | |
| 23 | 21 | import static org.hamcrest.Matchers.containsString; | |
@@ -152,19 +150,18 @@ public void copyFileWithExecutePermission() throws Exception { | |||
| 152 | 150 | ||
| 153 | 151 | @Test | |
| 154 | 152 | public void copyFileWithUIDGID() throws Exception { | |
| 155 | - Path withDir = Files.createTempDirectory("copyFileWithUIDGID"); | ||
| 156 | 153 | Path with = Files.createFile(Files.createTempDirectory("copyFileWithUIDGID").resolve("uidgid.with")); | |
| 157 | 154 | Files.write(with, "with".getBytes()); | |
| 158 | 155 | ||
| 159 | - Path withoutDir = Files.createTempDirectory("copyFileWithUIDGID"); | ||
| 160 | 156 | Path without = Files.createFile(Files.createTempDirectory("copyFileWithUIDGID").resolve("uidgid.without")); | |
| 161 | - Files.write(without, "with".getBytes()); | ||
| 157 | + Files.write(without, "without".getBytes()); | ||
| 162 | 158 | ||
| 163 | - String containerCmd = "while [ ! -f /home/uidgid.with ]; do true; done && echo uid=$(id -u) && stat -c %n:%u /home/uidgid.with /home/uidgid.without"; | ||
| 159 | + String containerCmd = "while [ ! -f /home/uidgid.with ]; do true; done && stat -c %n:%u /home/uidgid.with /home/uidgid.without"; | ||
| 160 | + Long syncUserUid = 4L; // sync user in busybox uses uid=4 | ||
| 164 | 161 | CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox") | |
| 165 | 162 | .withName("copyFileWithUIDGID") | |
| 166 | 163 | .withCmd("/bin/sh", "-c", containerCmd) | |
| 167 | - .withUser("sync") | ||
| 164 | + .withUser(syncUserUid.toString()) | ||
| 168 | 165 | .exec(); | |
| 169 | 166 | // start the container | |
| 170 | 167 | dockerRule.getClient().startContainerCmd(container.getId()).exec(); | |
@@ -197,12 +194,7 @@ public void copyFileWithUIDGID() throws Exception { | |||
| 197 | 194 | loggingCallback.awaitCompletion(3, TimeUnit.SECONDS); | |
| 198 | 195 | String containerOutput = loggingCallback.toString(); | |
| 199 | 196 | ||
| 200 | - Matcher uidMatcher = Pattern.compile("uid=(\\d+)").matcher(containerOutput); | ||
| 201 | - assertThat(String.format("cannot read effective uid on container from '%s'", containerOutput), uidMatcher.find(), equalTo(true)); | ||
| 202 | - assertThat(String.format("cannot read effective uid on container from '%s'", containerOutput), uidMatcher.groupCount(), equalTo(1)); | ||
| 203 | - Long containerEffectiveUid = Long.parseLong(uidMatcher.group(1)); | ||
| 204 | - | ||
| 205 | - assertThat(containerOutput, containsString(String.format("/home/uidgid.with:%d", containerEffectiveUid))); | ||
| 197 | + assertThat(containerOutput, containsString(String.format("/home/uidgid.with:%d", syncUserUid))); | ||
| 206 | 198 | ||
| 207 | 199 | Long hostUid = getHostUidIfPossible(); | |
| 208 | 200 | assumeThat("could not get the uid on host platform", hostUid, notNullValue(Long.class)); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments