Skip to content

task implement SUBSCRIBE and UNSUBSCRIBE commands with corresponding …#41

Merged
Aravinda-HWK merged 1 commit intomainfrom
39-task-implement-subscribe-command-and-write-the-test-cases
Oct 10, 2025
Merged

task implement SUBSCRIBE and UNSUBSCRIBE commands with corresponding …#41
Aravinda-HWK merged 1 commit intomainfrom
39-task-implement-subscribe-command-and-write-the-test-cases

Conversation

@Aravinda-HWK
Copy link
Copy Markdown
Collaborator

📌 Description

This PR is used to implement the "SUBSCRIBE" command and write the test cases for that command.


🔍 Changes Made

  1. Write the test cases for "SUBSCRIBE", "UNSUBSCRIBE", and "LSUB" commands
  2. Implement the above commands first.

✅ Checklist (Email System)

  • Core IMAP commands tested (LOGIN, CAPABILITY, LIST, SELECT, FETCH, LOGOUT).
  • Authentication is tested.
  • Docker build & run validated.
  • Configuration loading verified for default and custom paths.
  • Persistent storage with Docker volume verified.
  • Error handling and logging verified
  • Documentation updated (README, config samples).

🧪 Testing Instructions

To test the server, use the instructions in the README in the test directory.


📷 Screenshots / Logs (if applicable)


⚠️ Notes for Reviewers

@Aravinda-HWK Aravinda-HWK linked an issue Oct 9, 2025 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the SUBSCRIBE, UNSUBSCRIBE, and LSUB commands for the IMAP server with comprehensive test coverage. It adds subscription functionality that allows users to subscribe to mailboxes and list their subscribed mailboxes.

  • Implements SUBSCRIBE and UNSUBSCRIBE command handlers with proper authentication and validation
  • Adds LSUB command to list subscribed mailboxes, replacing hardcoded behavior with database-backed subscriptions
  • Creates comprehensive test suite covering various scenarios including edge cases and error conditions

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/server/subscribe_test.go Comprehensive test suite for SUBSCRIBE, UNSUBSCRIBE, and LSUB commands with 12 test cases
test/helpers/test_helpers.go Adds subscriptions table creation to test database setup
internal/server/testing.go Exposes subscription-related handlers for testing
internal/server/handlers.go Implements SUBSCRIBE, UNSUBSCRIBE handlers and updates LSUB to use database subscriptions
internal/server/connection.go Adds routing for SUBSCRIBE and UNSUBSCRIBE commands
internal/db/sqlite.go Adds database functions for subscription management
Makefile Adds test targets for subscription commands
.github/workflows/ci.yml Adds CI test steps for subscription commands

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread internal/server/handlers.go
Comment thread internal/server/handlers.go
@Aravinda-HWK Aravinda-HWK merged commit a3d46fe into main Oct 10, 2025
1 check passed
@Aravinda-HWK Aravinda-HWK deleted the 39-task-implement-subscribe-command-and-write-the-test-cases branch October 10, 2025 06:57
Aravinda-HWK added a commit that referenced this pull request Oct 11, 2025
Aravinda-HWK added a commit that referenced this pull request Oct 11, 2025
* fix: revert Go version to 1.25 in go.mod

* feat: add Dockerfile for building and running the IMAP server

* refactor: improve database initialization and handling of sample emails

* refactor: clarify comments and update build command in Dockerfile

* feat: implement new SQLite IMAP server with simplified connection handling

* feat: add SQLite database initialization with sample data insertion

* feat: add ClientState struct for managing IMAP client state

* feat: implement client handling logic for IMAP server connections

* feat: implement IMAP server fetch, select, search, and status handling

* feat: implement IMAP server handlers for capability, login, list, logout, and UID commands

* feat: add STARTTLS support to IMAP server and update capabilities

* feat: enhance login handling with external authentication and improved error responses

* feat: update login handling to use email instead of username

* fix: update database path in IMAP server initialization

* fix: update login response to reflect username usage instead of email

* refactor: remove test mail insertion logic from InitDB function

* refactor: remove unused imports from sqlite.go

* feat: implement IDLE command for real-time mailbox updates

* feat: add configuration loading from YAML file

* feat: load email domain from configuration file in handleLogin

* feat: add YAML dependency for configuration management

* feat: load TLS certificate paths from configuration file

* fix: expose both IMAP and secure IMAP ports in Dockerfile

* feat: implement SSL connection handling for IMAP server

* feat: enhance FETCH command response with additional attributes

* feat: add support for sequence ranges in FETCH command

* feat: enhance response logging to mask full message bodies

* feat: enhance UID FETCH command to support BODY.PEEK[] in response

* docs: update README to clarify server implementation and usage instructions

* fix: enable CGO in Dockerfile for proper SQLite support

* feat: add issue and pull request templates for better contribution guidelines

* fix: update issue template contact links for clarity and completeness

* fix: correct about text for Discussions link in issue template

* fix: remove obsolete issue template configuration file

* Add security policy documentation

* feat: add security policy and PGP public key documentation

* fix: update PGP public key link in security policy documentation

* Delete .github/SECURITY.md

* fix: correct PGP public key link in security policy documentation

* feat: add initial README documentation for Silver Go IMAP Server

* fix: remove unnecessary quotes from issue template fields in YAML files

* fix: add quotes around title in issue template YAML files

* feat: add contributing guidelines to the documentation

* Include Apache License 2.0

Added Apache License 2.0 to the project.

* Add LICENSE file

* Add Contributor Covenant Code of Conduct

This document outlines the Contributor Covenant Code of Conduct, establishing guidelines for community behavior, enforcement responsibilities, and consequences for violations.

* feat: add GitHub Actions workflow for publishing Docker images

* feat: add GitHub Actions workflow for publishing Docker images

* fix: update Docker image name in workflow and clarify permissions

* fix: update Docker image name to a specific repository in workflow

* fix: update Docker image name to match the correct repository

* fix: update workflow to trigger on release branch and use GITHUB_REF_NAME for versioning

* fix: update workflow to trigger on main branch instead of release

* 1 feature separate imap server into standalone service (#2)

* fix: improve pull request template formatting and clarity

* fix: remove indirect comments from go.mod and add missing dependency in go.sum

* fix: update Docker run command in README for improved clarity and functionality

* fix: refactor LoadConfig to handle multiple paths and improve error logging

* feat: add .gitignore to exclude configuration and data directories

* feat: add GitHub Actions workflow for publishing Docker images on release

* docs: update README for improved clarity and structure

* fix: update TLS certificate paths to use static locations instead of config

* Update .github/pull_request_template.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update internal/server/handlers.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add CI workflow for testing and building application

This CI workflow includes jobs for testing, linting, security scanning, building the application, and running integration tests.

* Simplify CI workflow by removing redundant steps

Removed various steps related to formatting, testing, coverage, linting, security scanning, and integration testing from the CI workflow.

* 4 task write test for capabilities command (#5)

* feat: enhance IMAP server capabilities and add authentication handling

* feat: add Makefile for Go IMAP server testing with various test targets

* fix: add certs directory to .gitignore

* feat: implement comprehensive testing for IMAP server capabilities and handlers

* feat: add CI workflow for automated testing of Go code

* Modify CI to run capability tests only

Updated CI workflow to run capability tests instead of all tests.

* Change capability test command to use make

* fix: update capability test command to include GOFLAGS

* refactor: simplify capability test commands by removing GOFLAGS and adding exact token matching

* feat: implement NOOP command handling and state tracking (#7)

- Added handleNoop function to manage NOOP command responses based on client state.
- Updated ClientState struct to track last message and recent counts.
- Enhanced CI workflow to include specific tests for NOOP command.
- Created comprehensive tests for NOOP command scenarios, including authenticated and unauthenticated states.

* feat: add LOGOUT command handling and tests (#8)

* feat: implement APPEND command handling and tests (#10)

* feat: enhance user table management and metadata tracking in database (#12)

* feat: implement AUTHENTICATE command handling with base64 support and tests (#10) (#14)

- Added AUTHENTICATE command handling in handlers.go with support for PLAIN mechanism.
- Implemented base64 encoding/decoding for credentials.
- Added tests for AUTHENTICATE command in authenticate_test.go covering various scenarios including TLS checks, case insensitivity, and malformed data.
- Updated Makefile and README.md to include new test commands and descriptions.
- Enhanced CI workflow to include tests for AUTHENTICATE command.

* 13 bug mails are not visible in apple mail mua (#15)

* feat: implement AUTHENTICATE command handling with base64 support and tests (#10)
- Added AUTHENTICATE command handling in handlers.go with support for PLAIN mechanism.
- Implemented base64 encoding/decoding for credentials.
- Added tests for AUTHENTICATE command in authenticate_test.go covering various scenarios including TLS checks, case insensitivity, and malformed data.
- Updated Makefile and README.md to include new test commands and descriptions.
- Enhanced CI workflow to include tests for AUTHENTICATE command.

* feat: enhance UID handling for FETCH and STORE commands with support for comma-separated sequences

* 13 bug mails are not visible in apple mail mua (#16)

* feat: implement AUTHENTICATE command handling with base64 support and tests (#10)
- Added AUTHENTICATE command handling in handlers.go with support for PLAIN mechanism.
- Implemented base64 encoding/decoding for credentials.
- Added tests for AUTHENTICATE command in authenticate_test.go covering various scenarios including TLS checks, case insensitivity, and malformed data.
- Updated Makefile and README.md to include new test commands and descriptions.
- Enhanced CI workflow to include tests for AUTHENTICATE command.

* feat: enhance UID handling for FETCH and STORE commands with support for comma-separated sequences

* feat: optimize BODY.PEEK and BODY response handling in UID FETCH command

* 13 bug mails are not visible in apple mail mua (#17)

* feat: implement AUTHENTICATE command handling with base64 support and tests (#10)
- Added AUTHENTICATE command handling in handlers.go with support for PLAIN mechanism.
- Implemented base64 encoding/decoding for credentials.
- Added tests for AUTHENTICATE command in authenticate_test.go covering various scenarios including TLS checks, case insensitivity, and malformed data.
- Updated Makefile and README.md to include new test commands and descriptions.
- Enhanced CI workflow to include tests for AUTHENTICATE command.

* feat: enhance UID handling for FETCH and STORE commands with support for comma-separated sequences

* feat: optimize BODY.PEEK and BODY response handling in UID FETCH command

* feat: enhance BODY.PEEK handling to support specific header fields extraction

* Update feature.yaml for feature request template

* Fix bug report title formatting (#19)

* Fix bug report title formatting

* fix: update task title formatting by adding a space

* Implement STARTTLS command handling and associated tests (#22)

* Refactor authentication responses to comply with RFC 3501, changing BAD to NO for failures and enhancing response messages for clarity. Add tests for authentication cancellation and response formats. (#23)

* Add LOGIN command handling and tests, enforcing TLS requirement per RFC 3501 (#24)

* Enhance FETCH command handling to support additional header formats and improve body retrieval logic. Update response formatting for RFC822 and BODY commands. (#26)

* 25 bug mails can not be read from thunderbird (#27)

* Enhance FETCH command handling to support additional header formats and improve body retrieval logic. Update response formatting for RFC822 and BODY commands.

* Refactor FETCH and UID FETCH command handling to separate literal data storage and improve response formatting for header fields. Ensure compliance with requested formats.

* 25 bug mails can not be read from thunderbird (#28)

* Enhance FETCH command handling to support additional header formats and improve body retrieval logic. Update response formatting for RFC822 and BODY commands.

* Refactor FETCH and UID FETCH command handling to separate literal data storage and improve response formatting for header fields. Ensure compliance with requested formats.

* Implement code changes to enhance functionality and improve performance

* 25 bug mails can not be read from thunderbird (#29)

* Enhance FETCH command handling to support additional header formats and improve body retrieval logic. Update response formatting for RFC822 and BODY commands.

* Refactor FETCH and UID FETCH command handling to separate literal data storage and improve response formatting for header fields. Ensure compliance with requested formats.

* Implement code changes to enhance functionality and improve performance

* Add LSUB command handling to return subscribed folders

* 25 bug mails can not be read from thunderbird (#30)

* Enhance FETCH command handling to support additional header formats and improve body retrieval logic. Update response formatting for RFC822 and BODY commands.

* Refactor FETCH and UID FETCH command handling to separate literal data storage and improve response formatting for header fields. Ensure compliance with requested formats.

* Implement code changes to enhance functionality and improve performance

* Add LSUB command handling to return subscribed folders

* Enhance date formatting in handleFetch and update capabilities in authenticateUser

* 31 task check the select functionality and write the test cases for that (#32)

* Add SELECT and EXAMINE command handling with tests for unseen messages

* Implement EXAMINE command handling and tests for RFC 3501 compliance

* 33 task implement create command and write the test cases for that (#34)

* refactor: update project references from Silver Go IMAP to Kestrel

* feat: implement CREATE command for mailbox management and add related tests

* fix: update references from Kestrel to Raven in documentation and configuration

* fix: ensure CI workflow triggers on push to main branch

* 35 task implement the delete command and write the tes cases for that (#36)

* task remove push trigger from CI workflow

* feat: implement DELETE command functionality with tests

* refactor: clean up pull request template by removing unnecessary lines

* Update internal/db/sqlite.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* task implement RENAME command and add corresponding test cases (#38)

* Document configuration file and its fields

Added configuration file section with example and field descriptions.

* task implement SUBSCRIBE and UNSUBSCRIBE commands with corresponding database support and tests (#41)

* task implement unsubscribe command with validation checks and corresponding test cases (#42)

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Implement "SUBSCRIBE" command and write the test cases

2 participants