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

Add welcome mat with homepage redirects #583

Merged
merged 15 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
3 changes: 3 additions & 0 deletions .env.example.local
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ CF_API_TOKEN=
# https://nextjs.org/docs/app/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser
NEXT_PUBLIC_USER_INVITE_URL=https://account.dev.us-gov-west-1.aws-us-gov.cloud.gov/invite
NEXT_PUBLIC_CLOUD_SUPPORT_URL="mailto:[email protected]?body=What+is+your+question%3F%0D%0A%0D%0APlease+provide+your+application+name+or+URL.+Do+not+include+any+sensitive+information+about+your+platform+in+this+email."

# feed for cloud.gov blog posts
NEXT_PUBLIC_BLOG_FEED_URL=https://cloud.gov/updates.xml
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ CF_API_TOKEN=placeholder
CF_USER_ID=placeholder

NEXT_PUBLIC_USER_INVITE_URL=https://account.dev.us-gov-west-1.aws-us-gov.cloud.gov/invite
NEXT_PUBLIC_BLOG_FEED_URL=https://cloud.gov/updates.xml
53 changes: 29 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,45 @@ cf login -a api.fr.cloud.gov --sso

You do not need to target an organization or space.

### Step 3: Configure the application
### Step 3: Run a local user accounts and authentication (UAA) server

Users will need to authenticate through UAA in order to view the application. A real UAA flow can't be done locally, because UAA can't whitelist `localhost`. So in local development, we simulate this flow in two ways:

1) **By running a local UAA server** - This login flow provides fake `authsession` cookie data. This cookie is what allows you to visit authenticated pages when navigating the app.
2) **By setting CloudFoundry data in our environment file** - Because local UAA returns fake data, we need to obtain real CF credentials through the CF CLI and keep them in `.env.local`. This allows you to get real CloudFoundry API data. (Handled in steps 4 and 5.)

See the [uaa-docker README](uaa-docker/README.md) for set up instructions.

In another shell, start the UAA container:

```bash
cd uaa-docker
# follow instructions to build before running up
docker compose up
```

Use credentials found in `uaa-docker/uaa.yml` to log in.

### Step 4: Configure the application

Copy the example `.env.example.local` file. Do not check `.env.local` into source control.

```bash
cp .env.example.local .env.local
```

You do not need to change anything about this file for local development unless if you logged into your production cloud.gov account during the previous step.
You do not need to change anything about this file for local development unless you logged into your production cloud.gov account during the previous step.

```bash
# change this line if you are using production
CF_API_URL=https://api.fr.cloud.gov/v3
```

For certain pages, you'll also need to set your `CF_USER_ID`. This is normally returned from UAA and placed in the `authsession` cookie, but when working locally, you'll need to obtain this from your CloudFoundry environment (like by running `cf curl '/v3/users'`).

Note: the variable `CF_API_TOKEN` is not yet populated. That's okay! Continue to the next step to set it.

### Step 4: Run the app!
### Step 5: Run the app!

Start the app with the `dev-cf` command:

Expand All @@ -91,7 +112,7 @@ Due to developing locally against a "real" environment, we have to play by the r

If you start getting 401 errors, restart your application to get a new token. If you haven't logged into the CF CLI on a given day, make sure to reauthenticate following Step 2 above.

### Step 5: Optional stretch goals
### Step 6: Optional stretch goals

The above steps are enough to get most people up and running, but our app has more bells and whistles! Consider yourself good to go unless if you plan to do any of the following:

Expand Down Expand Up @@ -147,24 +168,8 @@ docker compose build
docker compose up
```

#### Local user accounts and authentication (UAA)

Our local version of the app uses a CF token to access the CF API. However, the deployed version of the application authenticates with the CF User Accounts and Authentication (UAA) service. We have a local version of UAA available if you wish to test or develop around the user experience of logging in.

See the [uaa-docker README](uaa-docker/README.md) for set up instructions.

Start the container:

```bash
cd uaa-docker
# follow instructions to build before running up
docker compose up
```

In order to try out UAA, you will need to comment out your CF_API_TOKEN and then use credentials found in the `uaa-docker/uaa.yml` file.


### Step 6: Testing
### Step 7: Testing

To run the entire unit test suite, you will need to start the docker database container:

Expand Down Expand Up @@ -199,7 +204,7 @@ Then, if you have not already, set up a [s3 service key](#s3-user-information).
npm run test:integration
```

### Step 7: Committing
### Step 8: Committing

#### Preparing your code

Expand Down Expand Up @@ -235,7 +240,7 @@ Cloud.gov requires any commits to this repo to be signed with a GPG key. [You wi

Cloud.gov requires that contributors have the [caulking tool](https://github.com/cloud-gov/caulking) installed and running on their machines. Follow the instructions to install caulking and confirm that `make audit` passes all checks.

## Step 8: Deploying
## Step 9: Deploying

This application is deployed to the cloud.gov development environment automatically when changes are merged into the main branch. Deployment is managed via Concourse CI (see the `ci` directory).

Expand All @@ -255,7 +260,7 @@ We prioritize named imports, TypeScript, and Pascal Case component names through

### Application structure

Next.js has few opinions about how to structure applications. We have chosen to use an MVC (Model View Controller)-like pattern.
Next.js has few opinions about how to structure applications. We have chosen to use an MVC (Model View Controller)-like pattern.

See our [architecture](docs/dev-practices/architecture.md) documentation for information about each of the layers and how we are using them.

Expand Down
81 changes: 81 additions & 0 deletions __tests__/api/blog/blog.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import nock from 'nock';
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
import { fetchXML, getBlogFeed } from '@/api/blog/blog';
import fs from 'node:fs';
import path from 'node:path';

const blogFeedXml = fs.readFileSync(
path.join(__dirname, '/../mocks/blogFeed.xml'),
'utf8'
);

const blogUrl = new URL(process.env.NEXT_PUBLIC_BLOG_FEED_URL);

beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
});

afterEach(() => {
nock.cleanAll();
// https://github.com/nock/nock#memory-issues-with-jest
nock.restore();
});

describe('fetchXML', () => {
describe('on success', () => {
it('returns xml as text', async () => {
// setup
nock(blogUrl.origin).get(blogUrl.pathname).reply(200, blogFeedXml);
// act
const result = await fetchXML(blogUrl);
// assert
expect(result).toEqual(blogFeedXml);
});
});
describe('on request error', () => {
it('throws error', async () => {
// setup
nock(blogUrl.origin).get(blogUrl.pathname).reply(500);
// act
expect(async () => {
await fetchXML(blogUrl);
}).rejects.toThrow();
});
});
});

describe('getBlogFeed', () => {
describe('on success', () => {
it('returns blog feed as parsed json', async () => {
// setup
nock(blogUrl.origin).get(blogUrl.pathname).reply(200, blogFeedXml);
// act
const blog = await getBlogFeed();
// assert
const post = blog.feed.entry[0];
const title = post.title._text;
const pubDate = post.published._text;
const link = post.id._text;
const summary = post.summary._cdata;
expect(title).toEqual('August 8th Cloud.gov Release Notes');
expect(pubDate).toEqual('2024-08-08T00:00:00+00:00');
expect(link).toEqual('https://cloud.gov/2024/08/08/release-notes');
expect(summary).toEqual(
'The Cloud.gov team is working on providing release notes so everyone can see new features and updates.'
);
});
});

describe('on request error', () => {
it('throws error', async () => {
// setup
nock(blogUrl.origin).get(blogUrl.pathname).reply(500);
// act
expect(async () => {
await getBlogFeed();
}).rejects.toThrow();
});
});
});
1 change: 1 addition & 0 deletions __tests__/api/mocks/blogFeed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.2">Jekyll</generator><link href="https://cloud.gov/updates.xml" rel="self" type="application/atom+xml" /><link href="https://cloud.gov/" rel="alternate" type="text/html" /><updated>2024-10-22T17:19:40+00:00</updated><id>https://cloud.gov/updates.xml</id><title type="html">cloud.gov</title><subtitle>Expedite your agency’s path to a secure and compliant cloud. cloud.gov provides an application environment that enables rapid deployment and ATO assessment for modern web applications.</subtitle><entry><title type="html">August 8th Cloud.gov Release Notes</title><link href="https://cloud.gov/2024/08/08/release-notes/" rel="alternate" type="text/html" title="August 8th Cloud.gov Release Notes" /><published>2024-08-08T00:00:00+00:00</published><updated>2024-08-08T19:21:35+00:00</updated><id>https://cloud.gov/2024/08/08/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The Cloud.gov team is working on providing release notes so everyone can see new features and updates.]]></summary></entry><entry><title type="html">May 30th Cloud.gov Release Notes</title><link href="https://cloud.gov/2024/05/30/release-notes/" rel="alternate" type="text/html" title="May 30th Cloud.gov Release Notes" /><published>2024-05-30T00:00:00+00:00</published><updated>2024-05-30T13:50:09+00:00</updated><id>https://cloud.gov/2024/05/30/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The Cloud.gov team is working on providing release notes so everyone can see new features and updates.]]></summary></entry><entry><title type="html">May 16th Cloud.gov Release Notes</title><link href="https://cloud.gov/2024/05/16/release-notes/" rel="alternate" type="text/html" title="May 16th Cloud.gov Release Notes" /><published>2024-05-16T00:00:00+00:00</published><updated>2024-05-16T17:51:52+00:00</updated><id>https://cloud.gov/2024/05/16/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The Cloud.gov team is working on providing release notes so everyone can see new features and updates.]]></summary></entry><entry><title type="html">April 18th cloud.gov Change Log</title><link href="https://cloud.gov/2024/04/18/release-notes/" rel="alternate" type="text/html" title="April 18th cloud.gov Change Log" /><published>2024-04-18T00:00:00+00:00</published><updated>2024-04-18T17:21:01+00:00</updated><id>https://cloud.gov/2024/04/18/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">April 4th cloud.gov Change Log</title><link href="https://cloud.gov/2024/04/04/release-notes/" rel="alternate" type="text/html" title="April 4th cloud.gov Change Log" /><published>2024-04-04T00:00:00+00:00</published><updated>2024-04-04T13:07:53+00:00</updated><id>https://cloud.gov/2024/04/04/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">March 21st cloud.gov Change Log</title><link href="https://cloud.gov/2024/03/21/release-notes/" rel="alternate" type="text/html" title="March 21st cloud.gov Change Log" /><published>2024-03-21T00:00:00+00:00</published><updated>2024-05-09T15:04:18+00:00</updated><id>https://cloud.gov/2024/03/21/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">March 7th cloud.gov Change Log</title><link href="https://cloud.gov/2024/03/07/release-notes/" rel="alternate" type="text/html" title="March 7th cloud.gov Change Log" /><published>2024-03-07T00:00:00+00:00</published><updated>2024-04-08T12:44:28+00:00</updated><id>https://cloud.gov/2024/03/07/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">February 23rd cloud.gov Change Log</title><link href="https://cloud.gov/2024/02/23/release-notes/" rel="alternate" type="text/html" title="February 23rd cloud.gov Change Log" /><published>2024-02-23T00:00:00+00:00</published><updated>2024-02-23T17:35:47+00:00</updated><id>https://cloud.gov/2024/02/23/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">February 8th cloud.gov Change Log</title><link href="https://cloud.gov/2024/02/08/release-notes/" rel="alternate" type="text/html" title="February 8th cloud.gov Change Log" /><published>2024-02-08T00:00:00+00:00</published><updated>2024-02-08T18:12:33+00:00</updated><id>https://cloud.gov/2024/02/08/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">January 25th cloud.gov Change Log</title><link href="https://cloud.gov/2024/01/25/release-notes/" rel="alternate" type="text/html" title="January 25th cloud.gov Change Log" /><published>2024-01-25T00:00:00+00:00</published><updated>2024-01-25T13:28:27+00:00</updated><id>https://cloud.gov/2024/01/25/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">December 29th cloud.gov Change Log</title><link href="https://cloud.gov/2023/12/29/release-notes/" rel="alternate" type="text/html" title="December 29th cloud.gov Change Log" /><published>2023-12-29T00:00:00+00:00</published><updated>2023-12-29T17:51:48+00:00</updated><id>https://cloud.gov/2023/12/29/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">December 12th cloud.gov Change Log</title><link href="https://cloud.gov/2023/12/12/release-notes/" rel="alternate" type="text/html" title="December 12th cloud.gov Change Log" /><published>2023-12-12T00:00:00+00:00</published><updated>2023-12-12T18:15:41+00:00</updated><id>https://cloud.gov/2023/12/12/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">November 27th cloud.gov Change Log</title><link href="https://cloud.gov/2023/11/27/release-notes/" rel="alternate" type="text/html" title="November 27th cloud.gov Change Log" /><published>2023-11-27T00:00:00+00:00</published><updated>2023-11-27T16:26:15+00:00</updated><id>https://cloud.gov/2023/11/27/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">New platform protections against malicious activity</title><link href="https://cloud.gov/2023/11/09/platform-protections/" rel="alternate" type="text/html" title="New platform protections against malicious activity" /><published>2023-11-09T00:00:00+00:00</published><updated>2023-11-09T21:01:40+00:00</updated><id>https://cloud.gov/2023/11/09/platform-protections</id><author><name></name></author><summary type="html"><![CDATA[In response to some recent incidents that caused outages on the platform, the cloud.gov team has added new platform protections against malicious activity. Notably, the team has added rate limiting by IP address to mitigate the effect of surges of malicious traffic on the platform.]]></summary></entry><entry><title type="html">November 9th cloud.gov Change Log</title><link href="https://cloud.gov/2023/11/09/release-notes/" rel="alternate" type="text/html" title="November 9th cloud.gov Change Log" /><published>2023-11-09T00:00:00+00:00</published><updated>2023-11-14T22:57:38+00:00</updated><id>https://cloud.gov/2023/11/09/release-notes</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov team is working on providing change logs so everyone can see new features and updates.]]></summary></entry><entry><title type="html">Updating existing instances to gp3 storage volumes is now supported</title><link href="https://cloud.gov/2023/10/11/update-existing-instances-gp3-now-available/" rel="alternate" type="text/html" title="Updating existing instances to gp3 storage volumes is now supported" /><published>2023-10-11T00:00:00+00:00</published><updated>2023-10-11T15:50:42+00:00</updated><id>https://cloud.gov/2023/10/11/update-existing-instances-gp3-now-available</id><author><name></name></author><summary type="html"><![CDATA[Updating to gp3 storage volumes for existing RDS and Elasticsearch/Opensearch instances is now supported]]></summary></entry><entry><title type="html">cloud.gov Page’s Federalist ATO Extension</title><link href="https://cloud.gov/2023/09/25/federalist-ato/" rel="alternate" type="text/html" title="cloud.gov Page’s Federalist ATO Extension" /><published>2023-09-25T00:00:00+00:00</published><updated>2023-09-28T22:26:41+00:00</updated><id>https://cloud.gov/2023/09/25/federalist-ato</id><author><name></name></author><summary type="html"><![CDATA[The cloud.gov Pages’s Federalist ATO has been extended until February 28th, 2024]]></summary></entry><entry><title type="html">Brokered storage volumes upgraded to gp3</title><link href="https://cloud.gov/2023/09/18/storage-volumes-gp3/" rel="alternate" type="text/html" title="Brokered storage volumes upgraded to gp3" /><published>2023-09-18T00:00:00+00:00</published><updated>2023-09-18T20:59:17+00:00</updated><id>https://cloud.gov/2023/09/18/storage-volumes-gp3</id><author><name></name></author><summary type="html"><![CDATA[Storage volumes across all brokered plans have been upgraded to gp3]]></summary></entry><entry><title type="html">Announcing FedRAMP CSP Community mailing list</title><link href="https://cloud.gov/2023/08/01/fedramp-csp-community/" rel="alternate" type="text/html" title="Announcing FedRAMP CSP Community mailing list" /><published>2023-08-01T00:00:00+00:00</published><updated>2023-08-01T19:37:53+00:00</updated><id>https://cloud.gov/2023/08/01/fedramp-csp-community</id><author><name></name></author><summary type="html"><![CDATA[Email [email protected] from your CSP email to join]]></summary></entry><entry><title type="html">New versions of PostgreSQL supported</title><link href="https://cloud.gov/2023/08/01/postgresql-versions-update/" rel="alternate" type="text/html" title="New versions of PostgreSQL supported" /><published>2023-08-01T00:00:00+00:00</published><updated>2024-08-02T14:06:54+00:00</updated><id>https://cloud.gov/2023/08/01/postgresql-versions-update</id><author><name></name></author><summary type="html"><![CDATA[PostgreSQL versions 13, 14, and 15 are now fully supported on cloud.gov]]></summary></entry></feed>
Loading